From 7f6066701e61dfd607a5be7e44c1a84b70c3051c Mon Sep 17 00:00:00 2001 From: iomgaa Date: Mon, 10 Aug 2026 03:42:03 -0400 Subject: [PATCH] =?UTF-8?q?style(tests):=20=E9=82=A3=E4=B8=AA=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E5=B4=A9=E6=BA=83=E7=9A=84=E5=BC=82=E5=B8=B8=E6=94=B9?= =?UTF-8?q?=E5=90=8D=E5=B8=A6=20Error=20=E5=90=8E=E7=BC=80=EF=BC=8C?= =?UTF-8?q?=E8=BF=87=20ruff=20N818?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一个提交串在 make ci 后面,ci 挂了 commit 照样跑了——这是把两件事写进一条命令的代价。 --- tests/unit/test_round_trip.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/unit/test_round_trip.py b/tests/unit/test_round_trip.py index 8c39f6e..2424d38 100644 --- a/tests/unit/test_round_trip.py +++ b/tests/unit/test_round_trip.py @@ -44,7 +44,7 @@ SYNTHETIC = SyntheticObservations( ) -class _Crash(RuntimeError): +class _CrashError(RuntimeError): """模拟进程被杀。它不是存储故障,是「这个进程不存在了」。""" @@ -62,7 +62,7 @@ class _CrashingStore: def _tick(self) -> None: self.writes += 1 if self.writes > self._crash_after: - raise _Crash(f"第 {self.writes} 次写之前进程没了") + raise _CrashError(f"第 {self.writes} 次写之前进程没了") async def write_run_started(self, record) -> None: self._tick() @@ -233,7 +233,7 @@ async def test_crashing_at_any_write_boundary_resumes_to_the_same_result( _definition(crashing), _request(_ScriptedExecutor(), registry, model_replay=ReplayPolicy.SAFE), ) - except _Crash: + except _CrashError: pass else: # 崩点排在最后一次写之后,这次运行其实跑完了。 @@ -270,7 +270,7 @@ async def test_the_history_the_model_sees_after_resuming_matches_the_uninterrupt directory = tmp_path / "crashed" # 崩在第一步的步记录落盘之后(第 5 次写),第二步一个字都没写。 crashing = _CrashingStore(JsonlRunStore(directory=directory), crash_after=5) - with pytest.raises(_Crash): + with pytest.raises(_CrashError): await run( _definition(crashing), _request(_ScriptedExecutor(), registry, model_replay=ReplayPolicy.SAFE), @@ -303,7 +303,7 @@ async def test_an_unreplayable_action_stops_at_unknown_instead_of_guessing( registry = _registry(replay_policy=ReplayPolicy.NEVER) # 第 4 次写是第一步的动作意图;崩在它之后,步记录就没写。 crashing = _CrashingStore(JsonlRunStore(directory=directory), crash_after=4) - with pytest.raises(_Crash): + with pytest.raises(_CrashError): await run( _definition(crashing), _request(_ScriptedExecutor(), registry, model_replay=ReplayPolicy.NEVER), @@ -327,7 +327,7 @@ async def test_an_unreplayable_model_call_stops_at_unknown(tmp_path: Path) -> No registry = _registry(replay_policy=ReplayPolicy.NEVER) # 第 2 次写是第一步的模型调用意图。 crashing = _CrashingStore(JsonlRunStore(directory=directory), crash_after=2) - with pytest.raises(_Crash): + with pytest.raises(_CrashError): await run( _definition(crashing), _request(_ScriptedExecutor(), registry, model_replay=ReplayPolicy.NEVER), @@ -350,7 +350,7 @@ async def test_a_resumed_log_survives_a_second_resume(tmp_path: Path) -> None: directory = tmp_path / "twice" registry = _registry(replay_policy=ReplayPolicy.SAFE) crashing = _CrashingStore(JsonlRunStore(directory=directory), crash_after=2) - with pytest.raises(_Crash): + with pytest.raises(_CrashError): await run( _definition(crashing), _request(_ScriptedExecutor(), registry, model_replay=ReplayPolicy.SAFE), @@ -358,7 +358,7 @@ async def test_a_resumed_log_survives_a_second_resume(tmp_path: Path) -> None: # 第一次续跑:重放那次模型调用,再崩在下一步的动作意图之后。 second = _CrashingStore(JsonlRunStore(directory=directory), crash_after=3) - with pytest.raises(_Crash): + with pytest.raises(_CrashError): await resume( _definition(second), _request(_ScriptedExecutor(), registry, model_replay=ReplayPolicy.SAFE),