@@ -355,34 +355,6 @@ def tell(self):
355355 assert client ._is_seekable_stream (CustomSeekableStream ())
356356
357357
358- def test_no_retry_on_non_seekable_stream ():
359- requests = []
360-
361- # Always respond with a response that triggers a retry.
362- def inner (h : BaseHTTPRequestHandler ):
363- content_length = int (h .headers .get ('Content-Length' , 0 ))
364- if content_length > 0 :
365- requests .append (h .rfile .read (content_length ))
366-
367- h .send_response (429 )
368- h .send_header ('Retry-After' , '1' )
369- h .end_headers ()
370-
371- stream = io .BytesIO (b"test data" )
372- stream .seekable = lambda : False # makes the stream appear non-seekable
373-
374- with http_fixture_server (inner ) as host :
375- client = _BaseClient ()
376-
377- # Should raise error immediately without retry.
378- with pytest .raises (DatabricksError ):
379- client .do ('POST' , f'{ host } /foo' , data = stream )
380-
381- # Verify that only one request was made (no retries).
382- assert len (requests ) == 1
383- assert requests [0 ] == b"test data"
384-
385-
386358@pytest .mark .parametrize ('input_data' , [
387359 b"0123456789" , # bytes -> BytesIO
388360 "0123456789" , # str -> BytesIO
@@ -443,34 +415,29 @@ def inner(h: BaseHTTPRequestHandler):
443415 assert input_data .tell () == 10 # EOF
444416
445417
446- def test_do_not_reset_nonseekable_stream_on_retry ():
447- received_data = []
418+ def test_no_retry_or_reset_on_non_seekable_stream ():
419+ requests = []
448420
449421 # Always respond with a response that triggers a retry.
450422 def inner (h : BaseHTTPRequestHandler ):
451423 content_length = int (h .headers .get ('Content-Length' , 0 ))
452424 if content_length > 0 :
453- received_data .append (h .rfile .read (content_length ))
425+ requests .append (h .rfile .read (content_length ))
454426
455427 h .send_response (429 )
456428 h .send_header ('Retry-After' , '1' )
457429 h .end_headers ()
458430
459- stream = io .BytesIO (b"0123456789" )
460- stream .seekable = lambda : False # makes the stream appear non-seekable
461-
462- # Read some data from the stream first to verify that the stream is
463- # reset to the correct position rather than to its beginning.
464- stream .seek (4 )
431+ input_data = io .BytesIO (b"0123456789" )
432+ input_data .seekable = lambda : False # makes the stream appear non-seekable
465433
466434 with http_fixture_server (inner ) as host :
467435 client = _BaseClient ()
468436
469- # Should fail without resetting the stream .
437+ # Should raise error immediately without retry .
470438 with pytest .raises (DatabricksError ):
471- client .do ('POST' , f'{ host } /foo' , data = stream )
472-
473- assert received_data == [b"456789" ]
439+ client .do ('POST' , f'{ host } /foo' , data = input_data )
474440
475- # Verify stream was NOT reset to initial position.
476- assert stream .tell () == 10 # EOF
441+ # Verify that only one request was made (no retries).
442+ assert requests == [b"0123456789" ]
443+ assert input_data .tell () == 10 # EOF
0 commit comments