The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(pm): trim download-continuity tests to invariants
Tekniumbb11d6ac057f
diff --git a/tests/pm/test_download_continuity.py b/tests/pm/test_download_continuity.pyindex af843d994e7..5a31a42085f 100644--- a/tests/pm/test_download_continuity.py+++ b/tests/pm/test_download_continuity.py@@ -57,7 +57,6 @@ def test_download_retries_renew_only_while_bytes_are_saved(tmp_path, monkeypatchwith pytest.raises(DownloadTransportError):download.run()assert not destination.exists()- assert download._durable_done == blockassert [start for start, _ in requests] == [0, block, block, block, block]else:download.run()@@ -115,7 +114,7 @@ def test_forced_termination_recovers_checkpoint_before_request_finishes(tmp_pathtry:assert waiting.wait(10), "child never received model data"assert wait_until(side.is_file, timeout=10), "no checkpoint during an unfinished request"- saved = json.loads(side.read_text())+ saved = json.loads(side.read_text(encoding="utf-8-sig"))retained = sum(end - start for start, end in saved["ranges"])assert retained >= checkpointfinally:@@ -158,12 +157,12 @@ def test_failed_periodic_checkpoint_retries_without_claiming_saved_bytes(tmp_patcovered, errors = download._ranged_attempt(source, remote, part, [], 1, lambda _: None)assert not errors and covered == [(0, len(payload))]assert attempts == [0, 0]- assert json.loads(side.read_text())["ranges"] == [[0, len(payload)]]+ assert json.loads(side.read_text(encoding="utf-8-sig"))["ranges"] == [[0, len(payload)]]assert download._durable_done == len(payload)assert any(record.name == "pm.downloader" and record.levelname == "WARNING" for record in caplog.records)[email protected]("retry_after", [5, 120, 290, 600])[email protected]("retry_after", [5, 290, 600])def test_long_primary_wait_yields_to_a_mirror_that_can_wait_longer(tmp_path, monkeypatch, dl_server, retry_after):payload = b"pinned mirror bytes"RangeHandler.payloads = {"/primary": payload, "/mirror": payload}diff --git a/tests/pm/test_network.py b/tests/pm/test_network.pyindex a0d27759e68..5793f763053 100644--- a/tests/pm/test_network.py+++ b/tests/pm/test_network.py@@ -116,7 +116,7 @@ def test_download_failure_names_only_a_cdn_firewall_refusal(status, headers, cdnassert f"mirror.example's CDN firewall ({cdn}) refused this network" in message, message[email protected]("retry_after,expected", [("7", 7), ("60", 60), ("600", None)])[email protected]("retry_after,expected", [("60", 60), ("600", None)])def test_resumable_transfer_honors_retry_after_or_stops(retry_after, expected):attempts = []waits = []