Skip to content

Commit 778232a

Browse files
committed
Handle test cleanup better.
1 parent c034428 commit 778232a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

aws_doc_sdk_examples_tools/fs_test.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,20 @@ def path_factory(content: str) -> Path:
6060
run_common_readlines_scenarios(fs, path_factory)
6161
finally:
6262
# Clean up temp files
63+
errors = []
6364
for path in temp_files:
64-
if path.exists():
65-
path.unlink()
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(
75+
f"Errors occurred while cleaning up temp files:\n{messages}"
76+
)
6677

6778

6879
class TestRecordFs:

0 commit comments

Comments
 (0)