Files
cad-agent/conftest.py
T
gjm 0656397a68 test(review): 新增 pytest 离线回归网,锁定 dwg_review 既有行为
在改动审查流水线(确定性检查前置 / 结论结构化 / 证据交叉校验)之前,
先立一张离线、确定性、秒级的回归网。

- tests/fakes.py:假 LLM + 假 MCP 基座 + 响应构造器(ok_text/ok_image/err)
  + make_ctx/make_evidence,绝不触网、不读密钥
- 10 个模块共 134 用例:
  mcp_client / llm_client / cad_tools / checklist / config /
  planning / evidence / review / report / annotator
- pytest.ini(testpaths=tests)+ requirements-dev.txt + 根 conftest.py
  (sys.path + RENDER_WAIT=0 / REPORT_DIR=tmp fixture)
2026-10-14 19:07:27 +08:00

32 lines
959 B
Python

"""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