conftest.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import sys
  2. import os
  3. sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
  4. import pytest
  5. from PySide6.QtWidgets import QApplication
  6. @pytest.fixture(scope="session")
  7. def qapp():
  8. app = QApplication.instance()
  9. if app is None:
  10. app = QApplication(sys.argv)
  11. yield app
  12. @pytest.fixture(scope="session")
  13. def sample_config_path(tmp_path_factory):
  14. tmpdir = tmp_path_factory.mktemp("config")
  15. cfg = tmpdir / "config.ini"
  16. cfg.write_text(
  17. """[App]
  18. name = 测试系统
  19. copyright = 测试
  20. screen = 0
  21. [Video]
  22. rtsp_timeout = 5
  23. [Hardware]
  24. module_type = RFID
  25. [RFID]
  26. ip = 192.168.1.1
  27. port = 60000
  28. stability_time = 5
  29. stability_count = 3
  30. [AI]
  31. enabled = false
  32. broker = 127.0.0.1
  33. port = 1883
  34. topics =
  35. [NVR]
  36. count = 0
  37. [Bucket]
  38. count = 1
  39. [Bucket:0]
  40. id = 1
  41. description = 测试工位
  42. code_x = TEST001
  43. code_y = 1
  44. left_rtsp = rtsp://test:test@192.168.1.10:554/stream1
  45. right_rtsp = rtsp://test:test@192.168.1.11:554/stream2
  46. left_topic = test/left
  47. right_topic = test/right
  48. """, encoding="utf-8"
  49. )
  50. return str(cfg)