-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Can't get proper captured log call #3621
Comments
GitMate.io thinks possibly related issues are #2647 (call to pytest_runtest_logreport is not proper ), #225 (finalizer function does not get called), #447 (Fixture params not accessible inside the fixture, not getting called multiple times.), #1210 (msg in pytest.exit(msg) doesn't get printed when called in pytest hook), and #2616 (The plugin hooks pytest_cmdline_parse and pytest_load_initial_conftests don't appear to get called). |
Hi @kiddick, Currently the captured logs are only shown if a test fails. I suppose you want your test to fail instead of just showing up an warning, so I think you can write a fixture which fails a test if it captures an specific logging message. Untested: @pytest.fixture(autouse=True)
def error_on_async_callback(caplog):
for r in caplog.records:
if 'Exception in callback' in r.message:
assert False, f'Error logged in callback: {r.message}' |
HI @nicoddemus! Thank you for reply, I'll test this approach. May be it is reasonable to consider some cli option to enable log capturing even with successful run. |
@kiddick I agree, currently we have |
Created #3633 to follow up the feature request so I'm closing this one. Thanks again @kiddick! |
Miniamal example to reproduce issue:
mycode.py
test_code.py
pytest -s test_code.py
run it with commented
raise
and get successful result w/o any reportbut there is an obvious issue with
add_done_callback
it will call that function with only one parameterso if we uncomment
raise
statement we will get additional detail calledCaptured log call
so is it possible to get that output with "successful" run?
The text was updated successfully, but these errors were encountered: