diff --git a/tests/tui/test_pilot.py b/tests/tui/test_pilot.py index 823b4a7..3a67e08 100644 --- a/tests/tui/test_pilot.py +++ b/tests/tui/test_pilot.py @@ -584,6 +584,7 @@ async def test_gc_previews_before_deleting(self, ctx, remote_root): await pilot.press("2") await _wait_for(lambda: isinstance(app.screen, EnvsScreen)) await pilot.press("g") + await _wait_for(lambda: isinstance(app.screen, ConfirmModal)) await pilot.pause() assert isinstance(app.screen, ConfirmModal) app.screen.query_one("#yes") diff --git a/tests/unit/test_env_executors.py b/tests/unit/test_env_executors.py index af92236..cea3de8 100644 --- a/tests/unit/test_env_executors.py +++ b/tests/unit/test_env_executors.py @@ -139,12 +139,17 @@ def _prepare( def _wait_for_process_exit(pid: int, *, timeout: float = 5.0) -> None: + if pid <= 0: + pytest.fail(f"invalid process ID: {pid}") + deadline = time.monotonic() + timeout while time.monotonic() < deadline: try: os.kill(pid, 0) - except OSError: + except ProcessLookupError: return + except OSError as exc: + pytest.fail(f"unable to inspect background process {pid}: {exc}") time.sleep(0.05) pytest.fail(f"background process {pid} did not exit within {timeout:.1f}s")