# MIT License # Copyright (c) 2024 """最小端到端测试:执行器 dry-run 模式。""" from autodemo.executor import ExecContext, execute_spec from autodemo.schema import DSLSpec def test_executor_dry_run(monkeypatch, capsys) -> None: # 替换 _match_window 与 _find_control 以避免真实 UI 依赖 from autodemo import executor def fake_match(title: str): class Dummy: Name = "Notepad" return Dummy() def fake_find(root, locator, timeout): return object() monkeypatch.setattr(executor, "_match_window", fake_match) monkeypatch.setattr(executor, "_find_control", fake_find) spec = DSLSpec(steps=[{"action": "click", "target": {"Name": "ok"}}]) ctx = ExecContext(allow_title=".*", dry_run=True) execute_spec(spec, ctx) out = capsys.readouterr().out assert "dry-run" in out