-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added printing of captured stdout before entering pdb #3186
Added printing of captured stdout before entering pdb #3186
Conversation
_pytest/debugging.py
Outdated
@@ -85,6 +85,8 @@ def _enter_pdb(node, excinfo, rep): | |||
# for not completely clear reasons. | |||
tw = node.config.pluginmanager.getplugin("terminalreporter")._tw | |||
tw.line() | |||
tw.sep(">", "captured stdout") |
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.
Perhaps we should print this only if there's any actual stdout:
stdout = rep.capstdout
if stdout:
tw.sep(">", "captured stdout")
tw.line(stdout)
And maybe we should also print stderr
?
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.
both sound good
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.
Awesome, thanks @brianmaissy!
@brianmaissy can you take a look at the failing test please? |
if len(captured_stderr) > 0: | ||
tw.sep(">", "captured stderr") | ||
tw.line(captured_stderr) | ||
|
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.
Please also output the captured logs (rep.caplog
) and make sure that they are not output if live-logging is enabled (-o log_cli=True -o log_level=DEBUG
)
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.
Note that rep.caplog
was added in the features branch. So you can't use it if you merge your branch into master, but you can copy'n'paste the implemenation of BaseReport.caplog from https://github.com/pytest-dev/pytest/pull/3156/files#diff-e1a5c52f502faf325466018a5440c400R260.
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.
Please also output the captured logs (rep.caplog) and make sure that they are not output if live-logging is enabled (-o log_cli=True -o log_level=DEBUG)
Why should we make a special case for living log here? I kind see the point, but we are dumping captured stdout/stderr at this point it follows that we should dump caplog then as well, regardless of live logging.
but you can copy'n'paste the implemenation of BaseReport.caplog from
If we end up doing this, please don't make caplog
public: we don't want to introduce a new public API in a bug-fix release.
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.
maybe it would be better to merge this and open a new issue to implement the same thing for caplog, in the features branch
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.
@brianmaissy fair enough. @Thisch do you agree?
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.
Ok. Let's do it like this
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.
Opened a new issue #3204
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.
finally got that failing test |
Great! I think you can squash your last three commits into one. (IMO you can squash all your commits into one. @nicoddemus, do you agree?) |
07bcd12
to
7656fc8
Compare
Thanks @brianmaissy! |
Thx again! |
Fixes #3052