Skip to content

Commit 84e5c54

Browse files
committed
Handle test cleanup better.
1 parent c034428 commit 84e5c54

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

aws_doc_sdk_examples_tools/fs_test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,18 @@ def path_factory(content: str) -> Path:
6060
run_common_readlines_scenarios(fs, path_factory)
6161
finally:
6262
# Clean up temp files
63-
for path in temp_files:
64-
if path.exists():
65-
path.unlink()
66-
63+
errors = []
64+
for path in temp_files:
65+
try:
66+
if path.exists():
67+
path.unlink()
68+
except Exception as e:
69+
errors.append((path, e))
70+
if errors:
71+
messages = "\n".join(
72+
f"{path}: {type(e).__name__}: {e}" for path, e in errors
73+
)
74+
pytest.fail(f"Errors occurred while cleaning up temp files:\n{messages}")
6775

6876
class TestRecordFs:
6977
"""Test RecordFs implementation of readlines."""

0 commit comments

Comments
 (0)