diff --git a/hatch.toml b/hatch.toml index 884bf6f..7dc684b 100644 --- a/hatch.toml +++ b/hatch.toml @@ -5,7 +5,7 @@ pre-install-commands = [ [envs.default.scripts] sync = "pip install -r requirements-testing.txt" -test = "pytest --cov-config pyproject.toml {args:test}" +test = "pytest --cov-config pyproject.toml {args}" typing = "mypy {args:src test}" style = [ "ruff check {args:.}", diff --git a/pyproject.toml b/pyproject.toml index 5d3c795..249f513 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -137,6 +137,9 @@ line-length = 100 [tool.pytest.ini_options] xfail_strict = false +testpaths = [ + "test" +] addopts = [ "-rfEx", "--durations=5", diff --git a/test/openjd/sessions/test_runner_base.py b/test/openjd/sessions/test_runner_base.py index e1c6911..234eb99 100644 --- a/test/openjd/sessions/test_runner_base.py +++ b/test/openjd/sessions/test_runner_base.py @@ -822,6 +822,7 @@ def test_cancel_notify( # Test that NOTIFY_THEN_CANCEL first signals a SIGTERM and then a SIGKILL # GIVEN + proc_id: Optional[int] = None logger = build_logger(queue_handler) with NotifyingRunner(logger=logger, session_working_directory=tmp_path) as runner: python_app_loc = ( @@ -833,6 +834,11 @@ def test_cancel_notify( secs = 2 if not is_windows() else 5 time.sleep(secs) # Give the process a little time to do something now = datetime.now(timezone.utc) + + assert runner._process is not None + assert runner._process._pid is not None + proc_id = runner._process._pid + runner.cancel(time_limit=timedelta(seconds=2)) # THEN @@ -849,9 +855,12 @@ def test_cancel_notify( messages = collect_queue_messages(message_queue) assert "Trapped" in messages trapped_idx = messages.index("Trapped") + process_exit_idx = messages.index( + f"Process pid {proc_id} exited with code: {runner.exit_code} (unsigned) / {hex(runner.exit_code)} (hex)" + ) # Should be at least one more number printed after the Trapped # to indicate that we didn't immediately terminate the script. - assert messages[trapped_idx + 1].isdigit() + assert any(msg.isdigit() for msg in messages[trapped_idx + 1 : process_exit_idx]) # Didn't get to the end assert "Log from test 9" not in messages # Notification file exists