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

Comments

Projects
None yet
3 participants
@brianmaissy
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

This comment has been minimized.

Contributor

brianmaissy commented Feb 10, 2018

@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.

@thisch

This comment has been minimized.

Contributor

thisch 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

This comment has been minimized.

Contributor

brianmaissy commented Feb 17, 2018

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

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Feb 17, 2018

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

@thisch

This comment has been minimized.

Contributor

thisch 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

This comment has been minimized.

Member

nicoddemus commented Feb 18, 2018

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

@thisch

This comment has been minimized.

Contributor

thisch commented Feb 20, 2018

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

@thisch thisch closed this Feb 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment