import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) import pytest from PySide6.QtWidgets import QApplication @pytest.fixture(scope="session") def qapp(): app = QApplication.instance() if app is None: app = QApplication(sys.argv) yield app @pytest.fixture(scope="session") def sample_config_path(tmp_path_factory): tmpdir = tmp_path_factory.mktemp("config") cfg = tmpdir / "config.ini" cfg.write_text( """[App] name = 测试系统 copyright = 测试 screen = 0 [Video] rtsp_timeout = 5 [Hardware] module_type = RFID [RFID] ip = 192.168.1.1 port = 60000 stability_time = 5 stability_count = 3 [AI] enabled = false broker = 127.0.0.1 port = 1883 topics = [NVR] count = 0 [Bucket] count = 1 [Bucket:0] id = 1 description = 测试工位 code_x = TEST001 code_y = 1 left_rtsp = rtsp://test:test@192.168.1.10:554/stream1 right_rtsp = rtsp://test:test@192.168.1.11:554/stream2 left_topic = test/left right_topic = test/right """, encoding="utf-8" ) return str(cfg)