diff --git a/tests/conftest.py b/tests/conftest.py index 52c78219a..7f58dbacc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,8 +5,8 @@ import pytest -@pytest.fixture(autouse=True) -def check_subprocesses(): +@pytest.fixture(autouse=True, scope='module') +def check_subprocesses(request, capsys): # Get a list of child PIDs before the test starts parent = psutil.Process(os.getpid()) before_children = {child.pid for child in parent.children(recursive=True)} @@ -20,4 +20,6 @@ def check_subprocesses(): leftover_details = [ f"PID {p.pid}: {p.cmdline()}" for p in parent.children(recursive=True) if p.pid in leftover_processes ] - pytest.fail(f"Lingering subprocesses detected:\n" + "\n".join(leftover_details)) + with capsys.disabled(): + print(f"Lingering subprocesses detected:\n" + "\n".join(leftover_details)) + pytest.fail()