Skip to content

Commit feb9426

Browse files
Address review comments
1 parent 5e2202f commit feb9426

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/test_base_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def inner(h: BaseHTTPRequestHandler):
345345
assert requests[0] == b"test data"
346346

347347

348-
def test_perform_resets_seekable_stream_on_error():
348+
def test_perform_resets_seekable_stream_on_retry():
349349
received_data = []
350350

351351
# Always respond with a response that triggers a retry.
@@ -360,14 +360,14 @@ def inner(h: BaseHTTPRequestHandler):
360360

361361
stream = io.BytesIO(b"0123456789") # seekable stream
362362

363+
# Read some data from the stream first to verify that the stream is
364+
# reset to the correct position rather than to its beginning.
365+
stream.read(4)
366+
assert stream.tell() == 4
367+
363368
with http_fixture_server(inner) as host:
364369
client = _BaseClient()
365370

366-
# Read some data from the stream first to verify that the stream is
367-
# reset to the correct position rather than to its beginning.
368-
stream.read(4)
369-
assert stream.tell() == 4
370-
371371
# Should fail but reset the stream.
372372
with pytest.raises(DatabricksError):
373373
client._perform('POST', f'{host}/foo', data=stream)
@@ -378,7 +378,7 @@ def inner(h: BaseHTTPRequestHandler):
378378
assert stream.tell() == 4
379379

380380

381-
def test_perform_does_not_reset_nonseekable_stream_on_error():
381+
def test_perform_does_not_reset_nonseekable_stream_on_retry():
382382
received_data = []
383383

384384
# Always respond with a response that triggers a retry.
@@ -394,14 +394,14 @@ def inner(h: BaseHTTPRequestHandler):
394394
stream = io.BytesIO(b"0123456789")
395395
stream.seekable = lambda: False # makes the stream appear non-seekable
396396

397+
# Read some data from the stream first to verify that the stream is
398+
# reset to the correct position rather than to its beginning.
399+
stream.read(4)
400+
assert stream.tell() == 4
401+
397402
with http_fixture_server(inner) as host:
398403
client = _BaseClient()
399404

400-
# Read some data from the stream first to verify that the stream is
401-
# reset to the correct position rather than to its beginning.
402-
stream.read(4)
403-
assert stream.tell() == 4
404-
405405
# Should fail without resetting the stream.
406406
with pytest.raises(DatabricksError):
407407
client._perform('POST', f'{host}/foo', data=stream)

0 commit comments

Comments
 (0)