@@ -421,7 +421,9 @@ def test_request_exceeds_quota_after_first_chunk():
421421 """Plan totals 4 sub-requests. The first response reports
422422 ``x-ratelimit-remaining=1`` — only 2 sub-requests fit total
423423 (the one just issued + 1 more). The wrapper must raise
424- ``RequestExceedsQuota`` *before* issuing chunk 2."""
424+ ``RequestExceedsQuota`` *before* issuing chunk 2, and the
425+ exception must carry a ``.call`` handle so the first chunk's
426+ already-fetched data is recoverable."""
425427 calls : list [dict ] = []
426428
427429 def fetch (args ):
@@ -438,6 +440,11 @@ def fetch(args):
438440 assert err .available == 2 # remaining=1 + the chunk we just spent
439441 assert err .deficit == 2
440442 assert len (calls ) == 1 , "only the first chunk should have been issued"
443+ # The originating ChunkedCall is exposed on .call so the first
444+ # chunk's already-fetched data is recoverable.
445+ assert err .call is not None
446+ assert err .call .completed_chunks == 1
447+ assert not err .call .partial_frame .empty
441448
442449
443450def test_request_exceeds_quota_message_reports_deficit ():
@@ -1262,22 +1269,3 @@ def fetch(args):
12621269 # .call carries the in-flight call so the user can recover.
12631270 assert err .call is not None
12641271 assert err .call .completed_chunks == 3
1265-
1266-
1267- def test_request_exceeds_quota_carries_call_handle ():
1268- """Regression: ``RequestExceedsQuota`` was a bare ``ValueError``
1269- with no ``.call`` attribute, so the first chunk's already-fetched
1270- data was unrecoverable. The exception now carries the originating
1271- ``ChunkedCall`` for symmetry with ``ChunkInterrupted``."""
1272-
1273- def fetch (args ):
1274- return pd .DataFrame ({"sites" : list (args ["sites" ])}), _quota_response (1 )
1275-
1276- decorated = multi_value_chunked (build_request = _fake_build , url_limit = 240 )(fetch )
1277- with pytest .raises (RequestExceedsQuota ) as excinfo :
1278- decorated ({"sites" : ["S1" * 10 , "S2" * 10 , "S3" * 10 , "S4" * 10 ]})
1279- err = excinfo .value
1280- assert err .call is not None
1281- # The already-fetched first chunk is accessible via .call.partial_frame.
1282- assert not err .call .partial_frame .empty
1283- assert err .call .completed_chunks == 1
0 commit comments