@@ -22,9 +22,14 @@ def test_header(pytester):
2222 def test_x(): pass
2323 """
2424 )
25- result = pytester .runpytest_subprocess ("--timeout=1" )
25+ result = pytester .runpytest_subprocess ("--timeout=1" , "--session-timeout=2" )
2626 result .stdout .fnmatch_lines (
27- ["timeout: 1.0s" , "timeout method:*" , "timeout func_only:*" ]
27+ [
28+ "timeout: 1.0s" ,
29+ "timeout method:*" ,
30+ "timeout func_only:*" ,
31+ "session timeout: 2.0s" ,
32+ ]
2833 )
2934
3035
@@ -606,15 +611,29 @@ def test_foo():
606611
607612
608613def test_session_timeout (pytester ):
614+ # 2 tests, each with 0.5 sec timeouts
615+ # each using a fixture with 0.5 sec setup and 0.5 sec teardown
616+ # So about 1.5 seconds per test, ~3 sec total,
617+ # Therefore:
618+ # A timeout of 1.25 sec should happen during the teardown of the first test
619+ # and the second test should NOT be run
609620 pytester .makepyfile (
610621 """
611- import time, pytest
622+ import time, pytest
612623
613- @pytest.mark.parametrize('i', range(10))
614- def test_foo(i):
615- time.sleep(1)
616- """
624+ @pytest.fixture()
625+ def slow_setup_and_teardown():
626+ time.sleep(0.5)
627+ yield
628+ time.sleep(0.5)
629+
630+ def test_one(slow_setup_and_teardown):
631+ time.sleep(0.5)
632+
633+ def test_two(slow_setup_and_teardown):
634+ time.sleep(0.5)
635+ """
617636 )
618- result = pytester .runpytest_subprocess ("--session-timeout" , "0.5 " )
619- result .stdout .fnmatch_lines (["*!! session-timeout: 0.5 sec exceeded !!!*" ])
637+ result = pytester .runpytest_subprocess ("--session-timeout" , "1.25 " )
638+ result .stdout .fnmatch_lines (["*!! session-timeout: 1.25 sec exceeded !!!*" ])
620639 result .assert_outcomes (passed = 1 )
0 commit comments