-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add --session-timeout #165
Changes from 10 commits
7ef1122
901762f
e4e357d
f6cd2e0
4d7e9e7
4e6063e
77ad48d
3351d99
44dc497
fcdc5eb
a611873
d01a14f
ea9fa95
ea6281e
ef5f18b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ docs/_build/ | |
|
||
# Virtual Envs | ||
.env* | ||
venv | ||
|
||
# IDE | ||
.idea | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,14 @@ def test_header(pytester): | |
def test_x(): pass | ||
""" | ||
) | ||
result = pytester.runpytest_subprocess("--timeout=1") | ||
result = pytester.runpytest_subprocess("--timeout=1", "--session-timeout=2") | ||
result.stdout.fnmatch_lines( | ||
["timeout: 1.0s", "timeout method:*", "timeout func_only:*"] | ||
[ | ||
"timeout: 1.0s", | ||
"timeout method:*", | ||
"timeout func_only:*", | ||
"session timeout: 2.0s", | ||
] | ||
) | ||
|
||
|
||
|
@@ -603,3 +608,32 @@ def test_foo(): | |
"pytest_timeout_cancel_timer", | ||
] | ||
) | ||
|
||
|
||
def test_session_timeout(pytester): | ||
# 2 tests, each with 0.5 sec timeouts | ||
# each using a fixture with 0.5 sec setup and 0.5 sec teardown | ||
# So about 1.5 seconds per test, ~3 sec total, | ||
# Therefore: | ||
# A timeout of 1.25 sec should happen during the teardown of the first test | ||
# and the second test should NOT be run | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think this is asserted? not immediately sure how you would assert it, maybe with more verbose output and more output lines to match. or maybe there's something easier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think this is addressed yet? |
||
pytester.makepyfile( | ||
""" | ||
import time, pytest | ||
|
||
@pytest.fixture() | ||
def slow_setup_and_teardown(): | ||
time.sleep(0.5) | ||
yield | ||
time.sleep(0.5) | ||
|
||
def test_one(slow_setup_and_teardown): | ||
time.sleep(0.5) | ||
|
||
def test_two(slow_setup_and_teardown): | ||
time.sleep(0.5) | ||
""" | ||
) | ||
result = pytester.runpytest_subprocess("--session-timeout", "1.25") | ||
result.stdout.fnmatch_lines(["*!! session-timeout: 1.25 sec exceeded !!!*"]) | ||
result.assert_outcomes(passed=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.25 from an edge is too brittle. experience tells me you can't really work with sub-seconds times in this test suite, it gets flaky otherwise.
Make the total test duration 2s and the session timeout 1s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the numbers in this description are now wrong. maybe just describe that this is designed to timeout during the first test and ensure the first test still runs to completion but the 2nd test is not started?