Skip to content

The agent that grows with you

test(channel_directory): fault the canonical JSON serializer, not json.dump

teknium13a75078c3d24
diff --git a/tests/gateway/test_channel_directory.py b/tests/gateway/test_channel_directory.py
index e8ae5ad35e6..cb01dae3763 100644
--- a/tests/gateway/test_channel_directory.py
+++ b/tests/gateway/test_channel_directory.py
@@ -58,12 +58,16 @@ class TestBuildChannelDirectoryWrites:
})
previous = json.loads(cache_file.read_text())
+ import utils
+
def broken_dump(data, fp, *args, **kwargs):
fp.write('{"updated_at":')
fp.flush()
raise OSError("disk full")
- monkeypatch.setattr(json, "dump", broken_dump)
+ # Fault the canonical writer's serializer (the seam the directory writes through), not
+ # json.dump — the helper serializes to a str first, so a stdlib patch never fires.
+ monkeypatch.setattr(utils, "_dump_json", broken_dump)
with patch("gateway.channel_directory.DIRECTORY_PATH", cache_file):
asyncio.run(build_channel_directory({}))