"""pytest 全局配置(位于仓库根,保证 `import dwg_review` 可用)。 注意:`dwg_review.config` 的常量在**导入期**就已定值,改 `os.environ` 不会生效, 所以测试里一律用 `monkeypatch.setattr(config, "XXX", ...)` 覆盖模块属性。 """ import pathlib import sys import pytest _ROOT = pathlib.Path(__file__).resolve().parent if str(_ROOT) not in sys.path: sys.path.insert(0, str(_ROOT)) @pytest.fixture(autouse=True) def _fast_defaults(monkeypatch): """单元测试默认:不等待渲染、取证只取整体单图(多图用例自行覆盖 tiles)。""" from dwg_review import config monkeypatch.setattr(config, "RENDER_WAIT", 0) monkeypatch.setattr(config, "EVIDENCE_DETAIL_TILES", 0) @pytest.fixture def tmp_reports(tmp_path, monkeypatch): """把报告输出目录指向临时目录,避免测试污染仓库的 reports/。""" from dwg_review import config monkeypatch.setattr(config, "REPORT_DIR", tmp_path) return tmp_path