Skip to content

Commit 530a605

Browse files
committed
Fix trailing whitespace in test docstrings and comments
Signed-off-by: xyuzh <xinyzng@gmail.com>
1 parent 8fdb894 commit 530a605

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

python/ray/data/tests/test_download_expression.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -296,22 +296,24 @@ def test_download_expression_with_null_uris(self):
296296

297297
def test_download_expression_with_invalid_uris(self, tmp_path):
298298
"""Test download expression with URIs that fail to download.
299-
300-
This tests the exception handling in load_uri_bytes (commit c9d91080fb)
299+
300+
This tests the exception handling in load_uri_bytes
301301
where OSError is caught and None is returned for failed downloads.
302302
"""
303303
# Create one valid file
304304
valid_file = tmp_path / "valid.txt"
305305
valid_file.write_bytes(b"valid content")
306-
306+
307307
# Create URIs: one valid, one non-existent file, one invalid path
308308
table = pa.Table.from_arrays(
309309
[
310-
pa.array([
311-
f"local://{valid_file}",
312-
f"local://{tmp_path}/nonexistent.txt", # File doesn't exist
313-
"local:///this/path/does/not/exist/file.txt", # Invalid path
314-
]),
310+
pa.array(
311+
[
312+
f"local://{valid_file}",
313+
f"local://{tmp_path}/nonexistent.txt", # File doesn't exist
314+
"local:///this/path/does/not/exist/file.txt", # Invalid path
315+
]
316+
),
315317
],
316318
names=["uri"],
317319
)
@@ -322,28 +324,26 @@ def test_download_expression_with_invalid_uris(self, tmp_path):
322324
# Should not crash - failed downloads return None
323325
results = ds_with_downloads.take_all()
324326
assert len(results) == 3
325-
327+
326328
# First URI should succeed
327329
assert results[0]["bytes"] == b"valid content"
328-
330+
329331
# Second and third URIs should fail gracefully (return None)
330332
assert results[1]["bytes"] is None
331333
assert results[2]["bytes"] is None
332334

333335
def test_download_expression_all_size_estimations_fail(self):
334336
"""Test download expression when all URI size estimations fail.
335-
336-
This tests the divide-by-zero fix (commit 095973428f) where failed
337-
size estimations append 0 instead of being skipped, and avg_nbytes_per_row == 0
338-
is checked to prevent division by zero.
337+
338+
This tests the failed download does not cause division by zero error.
339339
"""
340340
# Create URIs that will fail size estimation (non-existent files)
341341
# Using enough URIs to trigger size estimation sampling
342342
invalid_uris = [
343-
f"local:///nonexistent/path/file_{i}.txt"
343+
f"local:///nonexistent/path/file_{i}.txt"
344344
for i in range(30) # More than INIT_SAMPLE_BATCH_SIZE (25)
345345
]
346-
346+
347347
table = pa.Table.from_arrays(
348348
[pa.array(invalid_uris)],
349349
names=["uri"],
@@ -356,15 +356,17 @@ def test_download_expression_all_size_estimations_fail(self):
356356
# The PartitionActor should handle all failed size estimations gracefully
357357
# and fall back to using the number of rows in the block as partition size
358358
results = ds_with_downloads.take_all()
359-
359+
360360
# All downloads should fail gracefully (return None)
361361
assert len(results) == 30
362362
for result in results:
363363
assert result["bytes"] is None
364364

365-
def test_download_expression_mixed_valid_and_invalid_size_estimation(self, tmp_path):
365+
def test_download_expression_mixed_valid_and_invalid_size_estimation(
366+
self, tmp_path
367+
):
366368
"""Test download expression with mix of valid and invalid URIs for size estimation.
367-
369+
368370
This tests that size estimation handles partial failures correctly.
369371
"""
370372
# Create some valid files
@@ -373,7 +375,7 @@ def test_download_expression_mixed_valid_and_invalid_size_estimation(self, tmp_p
373375
file_path = tmp_path / f"valid_{i}.txt"
374376
file_path.write_bytes(b"x" * 100) # 100 bytes each
375377
valid_files.append(str(file_path))
376-
378+
377379
# Mix valid and invalid URIs
378380
mixed_uris = []
379381
for i in range(30):
@@ -383,7 +385,7 @@ def test_download_expression_mixed_valid_and_invalid_size_estimation(self, tmp_p
383385
else:
384386
# Others are invalid
385387
mixed_uris.append(f"local:///nonexistent/file_{i}.txt")
386-
388+
387389
table = pa.Table.from_arrays(
388390
[pa.array(mixed_uris)],
389391
names=["uri"],
@@ -395,7 +397,7 @@ def test_download_expression_mixed_valid_and_invalid_size_estimation(self, tmp_p
395397
# Should not crash - should handle mixed valid/invalid gracefully
396398
results = ds_with_downloads.take_all()
397399
assert len(results) == 30
398-
400+
399401
# Verify valid URIs downloaded successfully
400402
for i, result in enumerate(results):
401403
if i % 3 == 0 and i // 3 < len(valid_files):

0 commit comments

Comments
 (0)