-
Notifications
You must be signed in to change notification settings - Fork 64
Set timed_out attrib on reports for logging customization #90
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
Changes from 2 commits
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 |
---|---|---|
|
@@ -482,3 +482,36 @@ def custom_trace(*args): | |
module.custom_trace = custom_trace | ||
|
||
assert pytest_timeout.is_debugging(custom_trace) | ||
|
||
|
||
def test_logging_customization(testdir): | ||
testdir.makepyfile( | ||
conftest=""" | ||
import pytest | ||
|
||
@pytest.hookimpl(hookwrapper=True) | ||
def pytest_runtest_makereport(item, call): | ||
r = yield | ||
if not hasattr(r, "get_result"): | ||
return | ||
report = r.get_result() | ||
timed_out = False | ||
if hasattr(call.excinfo, "value"): | ||
msg = getattr(call.excinfo.value, "msg", None) | ||
if isinstance(msg, str) and msg.startswith("Timeout >"): | ||
timed_out = True | ||
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. What would you think of using 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 am not sure if the name thing would work: 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. regarding names, your test only contains two test names: But I think it's even better to parametrise this test and make a different conftest.py based on the parameter so it knows whether to expect a timeout or not 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. Okay, I'll try to push it into as many tests as I can. However, my schedule has changed a little so I had to postpone working on this to next week... 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 managed to get a wide-ranging implementation of the test for this pr working. It is very experimental let's say if not completely opaque and ugly. It uses a
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. @flub: If you find the time, I'd be glad to hear your opinion about that idea. 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. hi! again, thanks for your patience. |
||
assert bool(getattr(report, "timed_out", None)) == timed_out | ||
""" | ||
) | ||
testdir.makepyfile( | ||
""" | ||
import time | ||
|
||
def test_times_out(): | ||
time.sleep(2) | ||
|
||
def test_does_not_time_out(): | ||
time.sleep(0.1) | ||
""" | ||
) | ||
testdir.runpytest("--timeout=1", "-ss") |
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.
Great docs update! ❤️