From 7fb69df12d6a44fa7fdf084bd56fe4cdb3f43529 Mon Sep 17 00:00:00 2001 From: jlashner Date: Fri, 20 Dec 2024 12:18:02 -0800 Subject: [PATCH] test leftover process detection --- tests/conftest.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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()