Files
cad-agent/conftest.py
T

31 lines
959 B
Python
Raw Normal View History

"""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 _no_render_wait(monkeypatch):
"""消除 collect_frame 里每个图框的 RENDER_WAIT 等待(单元测试不需要真实渲染)。"""
from dwg_review import config
monkeypatch.setattr(config, "RENDER_WAIT", 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