Skip to content

Commit c339047

Browse files
test(tests): add coverage for _wait_for_file_to_exist error paths
ROOT CAUSE: CI coverage check failed because timeout error paths in _wait_for_file_to_exist() were not covered (99.96% instead of required 100%). CHANGES: - Added test_wait_for_file_to_exist_timeout() to test nonexistent file case - Added test_wait_for_file_to_exist_empty_file() to test empty file case IMPACT: Brings test_stdio.py coverage back to 100%, satisfying CI requirements. These error paths are now tested with realistic timeout scenarios. FILES MODIFIED: - tests/client/test_stdio.py
1 parent 5584cc6 commit c339047

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/client/test_stdio.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ async def _wait_for_file_to_exist(file_path: str, timeout: float = 5.0) -> None:
6262
raise TimeoutError(f"File {file_path} does not exist after {timeout}s")
6363

6464

65+
@pytest.mark.anyio
66+
async def test_wait_for_file_to_exist_timeout():
67+
"""Test _wait_for_file_to_exist raises TimeoutError when file doesn't exist."""
68+
nonexistent_file = "/tmp/nonexistent_file_test_1234567890"
69+
70+
with pytest.raises(TimeoutError, match="does not exist"):
71+
with anyio.fail_after(1.0):
72+
await _wait_for_file_to_exist(nonexistent_file, timeout=0.1)
73+
74+
75+
@pytest.mark.anyio
76+
async def test_wait_for_file_to_exist_empty_file():
77+
"""Test _wait_for_file_to_exist raises TimeoutError when file exists but is empty."""
78+
import tempfile
79+
80+
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
81+
empty_file = f.name
82+
83+
try:
84+
with pytest.raises(TimeoutError, match="exists but is empty"):
85+
with anyio.fail_after(1.0):
86+
await _wait_for_file_to_exist(empty_file, timeout=0.1)
87+
finally:
88+
os.unlink(empty_file)
89+
90+
6591
@pytest.mark.anyio
6692
@pytest.mark.skipif(tee is None, reason="could not find tee command")
6793
async def test_stdio_context_manager_exiting():

0 commit comments

Comments
 (0)