Skip to content

Commit

Permalink
add printing in error case
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Bokota <[email protected]>
  • Loading branch information
Czaki committed Apr 29, 2024
1 parent 83a09a6 commit bdaaada
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/pytest_pystack/_monitor_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
13 changes: 6 additions & 7 deletions tests/test_pytest_pystack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import pytest


pytest_plugins = 'pytester'


SLEEPING_TEST_TEMPLATE = """
import time
def test_sleeping_test():
Expand Down Expand Up @@ -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'
Expand All @@ -322,7 +321,7 @@ def test_pytester_compat(pytester, capfd):
def test_sleep():
time.sleep(3)
time.sleep(1)
assert 1 == 1
'''
Expand All @@ -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)
Expand Down

0 comments on commit bdaaada

Please sign in to comment.