61 """OI-517: no sandbox flag → legacy subprocess.run path."""
62 calls = {
"subprocess": 0,
"sandbox": 0}
64 def _fake_subprocess_run(*args, **kwargs):
65 calls[
"subprocess"] += 1
69 def __init__(self, *a, **kw):
72 def run(self, cmd, cwd, timeout):
75 monkeypatch.setattr(qg.subprocess,
"run", _fake_subprocess_run)
76 monkeypatch.setattr(
"oct.mcp.sandbox.SandboxExecutor", _FakeExecutor)
78 qg._run_test_pass(tmp_path, sandbox=
False)
79 assert calls[
"subprocess"] == 1
80 assert calls[
"sandbox"] == 0
84 """OI-517: sandbox=True → SandboxExecutor.run replaces subprocess.run."""
85 calls = {
"subprocess": 0,
"sandbox_run": 0}
87 def _fake_subprocess_run(*args, **kwargs):
88 calls[
"subprocess"] += 1
93 class _FakeSandboxResult:
94 def __init__(self, code):
96 self.timed_out =
False
99 def __init__(self, *a, **kw):
102 def run(self, cmd, cwd, timeout):
103 calls[
"sandbox_run"] += 1
104 captured[
"cmd"] = cmd
105 captured[
"cwd"] = cwd
106 captured[
"timeout"] = timeout
107 return _FakeSandboxResult(0)
109 monkeypatch.setattr(qg.subprocess,
"run", _fake_subprocess_run)
110 monkeypatch.setattr(
"oct.mcp.sandbox.SandboxExecutor", _FakeExecutor)
112 qg._run_test_pass(tmp_path, sandbox=
True)
113 assert calls[
"sandbox_run"] == 1
114 assert calls[
"subprocess"] == 0
115 assert captured[
"timeout"] == 600
116 assert "pytest" in captured[
"cmd"]