test(writer/qa): 覆盖 engine=None 委托工厂的真实门禁路径

This commit is contained in:
lhl
2026-08-13 23:13:58 +08:00
parent 2cd3ecd0f3
commit 24b9511d43
3 changed files with 27 additions and 1 deletions
+11
View File
@@ -54,3 +54,14 @@ def test_qa_loop_regenerates_only_failed(tmp_path):
assert report.passed is True
assert engine.calls["A"] == 1 # A 首次即通过,未被重生成
assert engine.calls["B"] == 2 # B 失败后被重生成一次
def test_run_delegates_to_factory_when_engine_none(monkeypatch, tmp_path):
# 门禁真实路径:engine=None 时应委托 build_inference_engine() 构造真实引擎
monkeypatch.setattr("genesis.qa.qa_loop.build_inference_engine", lambda: ImprovingEngine())
tpl = tmp_path / "tpl.docx"
out = tmp_path / "out.docx"
_make_template(str(tpl))
loop = QALoop(max_rounds=3)
report = loop.run(_ss(str(tpl)), str(out), samples_dir="nonexistent_dir_xyz", engine=None)
assert report.passed is True