style(tests): 那个模拟崩溃的异常改名带 Error 后缀,过 ruff N818
上一个提交串在 make ci 后面,ci 挂了 commit 照样跑了——这是把两件事写进一条命令的代价。
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user