diff --git a/src/pytest_pystack/_monitor_process.py b/src/pytest_pystack/_monitor_process.py index 100ec09..9f9b698 100644 --- a/src/pytest_pystack/_monitor_process.py +++ b/src/pytest_pystack/_monitor_process.py @@ -53,7 +53,9 @@ def _run_monitor(config: PystackConfig, pid, queue): handled_test_cases.add(testcase) try: - if queue.get(timeout=config.threshold) != testcase: + new_testcase = queue.get(timeout=config.threshold) + if new_testcase != testcase: + print(f"new test {new_testcase} should not start before previous {testcase} test finished", file=sys.__stderr__) raise Exception( "new test should not start before previous test finished" ) diff --git a/tests/test_pytest_pystack.py b/tests/test_pytest_pystack.py index 198eb8d..8daffb9 100644 --- a/tests/test_pytest_pystack.py +++ b/tests/test_pytest_pystack.py @@ -5,9 +5,6 @@ import pytest -pytest_plugins = 'pytester' - - SLEEPING_TEST_TEMPLATE = """ import time def test_sleeping_test(): @@ -309,11 +306,13 @@ def test_two_slow_tests_in_a_suite_prints_both(testdir, monkeypatch, capfd): assert "PYSTACK -- test_sleeping_test2" in stderr -def test_pytester_compat(pytester, capfd): +def test_pytester_compat(testdir, capfd, monkeypatch): """Make sure that our make_napari_viewer plugin works.""" # create a temporary pytest test file - pytester.makepyfile( + + monkeypatch.chdir(testdir.tmpdir) + testdir.makepyfile( """ pytest_plugins = 'pytester' @@ -322,7 +321,7 @@ def test_pytester_compat(pytester, capfd): def test_sleep(): - time.sleep(3) + time.sleep(1) assert 1 == 1 ''' @@ -333,7 +332,7 @@ def test_pytester(pytester): result.assert_outcomes(passed=1) """ ) - result = pytester.runpytest("--pystack-threshold=1", "-s") + result = testdir.runpytest("--pystack-threshold=3", "-s") # check that all 1 test passed result.assert_outcomes(passed=1)