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

Added printing of captured stdout before entering pdb #3186

Conversation

brianmaissy
Copy link
Contributor

Fixes #3052

@@ -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")
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both sound good

@coveralls
Copy link

coveralls commented Feb 3, 2018

Coverage Status

Coverage decreased (-0.04%) to 92.596% when pulling 7656fc8 on brianmaissy:bugfix/print_captured_stdout_before_entering_pdb into e7bcc85 on pytest-dev:master.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @brianmaissy!

@nicoddemus
Copy link
Member

@brianmaissy can you take a look at the failing test please?

if len(captured_stderr) > 0:
tw.sep(">", "captured stderr")
tw.line(captured_stderr)

Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@twmr twmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brianmaissy
Copy link
Contributor Author

finally got that failing test

@twmr
Copy link
Contributor

twmr commented Feb 12, 2018

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?)

@brianmaissy brianmaissy force-pushed the bugfix/print_captured_stdout_before_entering_pdb branch from 07bcd12 to 7656fc8 Compare February 12, 2018 21:18
@nicoddemus
Copy link
Member

Thanks @brianmaissy!

@nicoddemus nicoddemus merged commit 6bc45d1 into pytest-dev:master Feb 15, 2018
@twmr
Copy link
Contributor

twmr commented Feb 15, 2018

Thx again!

@brianmaissy brianmaissy deleted the bugfix/print_captured_stdout_before_entering_pdb branch February 16, 2018 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants