Skip to content

Commit fc80c4e

Browse files
Fix Python E2E test flakiness and missing pytest-timeout (#391)
- Add ignore_errors=True to shutil.rmtree() in test cleanup to handle race conditions where files are still being written by background processes - Add missing_ok=True to unlink() for same reason - Add pytest-timeout to dev dependencies (fixes warning about unknown mark)
1 parent 22fb64f commit fc80c4e

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

python/e2e/testharness/context.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,18 @@ async def configure_for_test(self, test_file: str, test_name: str):
100100
await self._proxy.configure(abs_snapshot_path, self.work_dir)
101101

102102
# Clear temp directories between tests (but leave them in place)
103+
# Use ignore_errors=True to handle race conditions where files may still
104+
# be written by background processes during cleanup
103105
for item in Path(self.home_dir).iterdir():
104106
if item.is_dir():
105-
shutil.rmtree(item)
107+
shutil.rmtree(item, ignore_errors=True)
106108
else:
107-
item.unlink()
109+
item.unlink(missing_ok=True)
108110
for item in Path(self.work_dir).iterdir():
109111
if item.is_dir():
110-
shutil.rmtree(item)
112+
shutil.rmtree(item, ignore_errors=True)
111113
else:
112-
item.unlink()
114+
item.unlink(missing_ok=True)
113115

114116
def get_env(self) -> dict:
115117
"""Return environment variables configured for isolated testing."""

python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dev = [
4242
"ty>=0.0.2",
4343
"pytest>=7.0.0",
4444
"pytest-asyncio>=0.21.0",
45+
"pytest-timeout>=2.0.0",
4546
"httpx>=0.24.0",
4647
]
4748

python/uv.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)