Skip to content
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

Print captured logs before entering pdb #3204

Closed
brianmaissy opened this issue Feb 10, 2018 · 7 comments
Closed

Print captured logs before entering pdb #3204

brianmaissy opened this issue Feb 10, 2018 · 7 comments
Labels
plugin: debugging related to the debugging builtin plugin plugin: logging related to the logging builtin plugin

Comments

@brianmaissy
Copy link
Contributor

brianmaissy commented Feb 10, 2018

Extension of PR #3186 for the caplog feature.

When a test fails and we are about the enter the debugger, we first print the traceback and the captured stdout and stderr. We need to add the captured logs. This is being opened as a separate ticket because caplog was added in the features branch, so if this issue is fixed before it gets merged, target the features branch for this issue as well.

See discussion here: https://github.com/pytest-dev/pytest/pull/3186/files#r166777807

@brianmaissy brianmaissy added plugin: capture related to the capture builtin plugin plugin: debugging related to the debugging builtin plugin labels Feb 10, 2018
@brianmaissy brianmaissy added plugin: logging related to the logging builtin plugin and removed plugin: capture related to the capture builtin plugin labels Feb 10, 2018
@brianmaissy
Copy link
Contributor Author

@nicoddemus @thisch So do you think we should still print captured logs at the end when live logging is on? It seems to me that as long as we capture something we should print it. Live logging is in addition to capturing, because if it's on we get the logs as they happen and also in the report if the test fails. I think the behavior before entering the debugger should parallel the failed test report.

@twmr
Copy link
Contributor

twmr commented Feb 17, 2018

I have some long running tests, which output a lot of log messages when I debug them. For debugging I use live-logging and --pdb. This allows me to abort the tests when I spot sth suspicious in the live-logs while the test is running).

For me it does not make sense to show the captured logs before entering pdb, since

1) the captured logs are not colored. IMO the captured logs are not as readable as the colored live-logs (see #3142).
2) the large number of logs generated by my tests is displayed twice (first the live-logs then the captured logs).

For the test reports it is possible to disable the printing of caught logs on failure (--no-print-logs). AFAIK this is not possible for the captured stdout/stderr, right (@Niccodemus)? --no-print-logs is not taken into account in your PR #3210.

It might make sense to only display the captured logs before entering pdb when --no-print-logs is not given.

WDYT?

@brianmaissy
Copy link
Contributor Author

Sounds good, I'll modify it to take into consideration the --no-print-logs option

@nicoddemus
Copy link
Member

Thanks @thisch for the explanation, indeed it makes sense to consider --no-print-logs to not print the logs in that case. 👍

@twmr
Copy link
Contributor

twmr commented Feb 17, 2018

BTW I would suggest to introduce a new generic --no-captured-output option and deprecate the --no-print-logs option. The --no-captured-output option disables the printing of captured output (stdout, stderr and logs) on failure and can also be used in the "enter pdb" code in #3186 and #3210.

@nicoddemus
Copy link
Member

@thisch I think this should go in a separate issue, would you mind opening it? Thanks!

@twmr
Copy link
Contributor

twmr commented Feb 20, 2018

Given that we've merged #3234, we can close this issue.

@twmr twmr closed this as completed Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: debugging related to the debugging builtin plugin plugin: logging related to the logging builtin plugin
Projects
None yet
Development

No branches or pull requests

3 participants