Test the judge's and the transcript's Stop from run_cycle

This commit is contained in:
2026-09-27 16:54:39 +02:00
parent 1a1ee613af
commit 70d816c830
+7 -2
View File
@@ -406,6 +406,11 @@ class RunCycle(unittest.TestCase):
with unittest.mock.patch("sys.stderr") as stderr:
self.assertEqual(loop.run_cycle(home, "task", "premises", "A name", SESSION_ID, "claude-opus-5-5"), loop.Stop(2, "stdin or stdout is not a terminal"))
self.assertIn(f"transcript: {loop.ARCHIVE}", "".join(str(call.args[0]) for call in stderr.write.call_args_list))
open(verdicts, "w").write("ask fail fail fail")
with unittest.mock.patch("sys.stderr"), unittest.mock.patch.object(loop, "interrupt", return_value=""):
self.assertEqual(loop.run_cycle(home, "task", "premises", "A name", SESSION_ID, "claude-opus-5-5").code, 1)
with unittest.mock.patch.object(loop, "session_file", return_value=""):
self.assertEqual(loop.run_cycle(home, "task", "premises", "A name", SESSION_ID, "claude-opus-5-5"), loop.Stop(1, f"claude left no transcript for session {SESSION_ID}"))
for plan in ("fail fail fail", "unquoted unquoted unquoted"):
open(verdicts, "w").write(plan)
stop = loop.run_cycle(home, "task", "premises", "A name", SESSION_ID, "claude-opus-5-5")
@@ -416,9 +421,9 @@ class RunCycle(unittest.TestCase):
self.assertEqual(open(verdicts).read(), "")
self.assertEqual({json.loads(line)[0] for line in open(calls)}, {home})
starts = [args[args.index("-p") + 1:][:3] for args in map(json.loads, open(calls)) if "--json-schema" not in args]
self.assertEqual([start[1] for start in starts], ["--name", "--resume", "--name", "--resume", "--resume", "--resume"])
self.assertEqual([start[1] for start in starts], ["--name", "--resume", "--name", "--resume", "--resume", "--name", "--resume", "--resume"])
self.assertEqual(starts[1][2], SESSION_ID)
self.assertEqual(sleep.call_count, 6)
self.assertEqual(sleep.call_count, 8)
self.assertEqual({args[args.index("--model") + 1] for args in map(json.loads, open(calls))}, {"claude-opus-5-5"})