@@ -22,9 +22,14 @@ def test_header(pytester):
22
22
def test_x(): pass
23
23
"""
24
24
)
25
- result = pytester .runpytest_subprocess ("--timeout=1" )
25
+ result = pytester .runpytest_subprocess ("--timeout=1" , "--session-timeout=2" )
26
26
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
+ ]
28
33
)
29
34
30
35
@@ -606,15 +611,29 @@ def test_foo():
606
611
607
612
608
613
def 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
609
620
pytester .makepyfile (
610
621
"""
611
- import time, pytest
622
+ import time, pytest
612
623
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
+ """
617
636
)
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 !!!*" ])
620
639
result .assert_outcomes (passed = 1 )
0 commit comments