Skip to content

Commit

Permalink
test leftover process detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jlashner committed Dec 20, 2024
1 parent c9a6115 commit 7fb69df
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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()

0 comments on commit 7fb69df

Please sign in to comment.