-
-
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
Add captured-log support to --show-capture #3234
Conversation
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 @Thisch, thanks! Please just update the other changelog entry as I requested, after this we can merge this.
Scratch that, as soon as CI passes we can merge this and then update the other changelog entry separately (even from GH's interface directly).
choices=['no', 'stdout', 'stderr', 'both'], default='both', | ||
help="Controls how captured stdout/stderr is shown on failed tests. " | ||
"Default is 'both'.") | ||
choices=['no', 'stdout', 'stderr', 'log', 'all'], default='all', |
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.
Good thinking, just realized that we definitely should have used all
instead of both
from the beginning. 😉
@@ -0,0 +1 @@ | |||
Captured logs are printed before entering pdb. |
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.
This reminds me, please update 1478.feature
as well. 👍
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.
Does towncrier reference this PR (#3234) then, or do we have to update the generated changelog manually?
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.
It uses the number in the filename to create a link, so the file above will link to #3204
545fbf7
to
51ece00
Compare
I would like to deprecate |
This option is superseded by the --show-capture option. With --no-print-logs it was possible to only disable the reporting of captured logs, which is no longer possible with --show-capture. If --show-capture=no is used, no captured content (stdout, stderr and logs) is reported for failed tests.
Unfortunately this is an API breakage, so we can only actually remove it in 4.0, we should deprecate it for now and create an issue to remove it in 4.0 using the deprecation label. |
Also I was thinking: the Perhaps accepting multiple values is best: |
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 deprecate --no-print-logs
Ok I'll revert my latest commit, but does it make sense to keep the changes made to the logging docu? --- a/doc/en/logging.rst
+++ b/doc/en/logging.rst
@@ -50,26 +50,10 @@ These options can also be customized through ``pytest.ini`` file:
log_format = %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
-Further it is possible to disable reporting logs on failed tests completely
-with::
+Further it is possible to disable reporting of captured content (stdout,
+stderr and logs) on failed tests completely with::
- pytest --no-print-logs
-
-Or in the ``pytest.ini`` file:
-
-.. code-block:: ini
-
- [pytest]
- log_print = False
-
-
-Shows failed tests in the normal manner as no logs were captured::
-
- ----------------------- Captured stdout call ----------------------
- text going to stdout
- ----------------------- Captured stderr call ----------------------
- text going to stderr
- ==================== 2 failed in 0.02 seconds =====================
+ pytest --show-capture=no |
@Thisch it does, thanks! Do you want to deprecate |
We'll deprecate --no-print-logs beginning with pytest-4.0. This reverts commit ac7eb63.
I've partially reverted my "remove --no-print-logs" commit now. Honestly, I don't see the use-case for multiple parameters for Maybe @s0undt3ch and @abusalimov want to comment on this, since they implemented/reviewed eisensheng/pytest-catchlog#34. (The question is the following: "are the 5 options for --show-capture (no, stdout, stderr, log, all) enough or do we want multiple parameters for --show-capture as suggested by @nicoddemus in #3234 (comment)?) |
Thanks!
I'm not sure, I suppose there are people that don't want to see logging output at all, but want to keep stdout/stderr intact (which is pytest's <3.3) behavior (see #3046). If nothing else, it might be problematic to simply remove/deprecate an option without offering an equivalent alternative. |
If they want that for whatever reason they can set the log-level to e.g. CRITICAL ( |
Indeed you got a point, and even better that solution can be controlled at the testing level (I mean setting the loglevel in a test using |
@nicoddemus how should I deprecate the --no-print-logs option? (I've never deprecated a pytest feature) |
Let's do it in #3238, we can merge it now. 👍 Thanks for all the work and patience! |
Implement the test from pytest-dev#3210, which was not merged yet, because the PR was abandoned in favor or pytest-dev#3234.
Fixes: #3233
Thanks for submitting a PR, your contribution is really appreciated!
Here's a quick checklist that should be present in PRs (you can delete this text from the final description, this is
just a guideline):
changelog
folder, with a name like<ISSUE NUMBER>.<TYPE>.rst
. See changelog/README.rst for details.master
branch for bug fixes, documentation updates and trivial changes.features
branch for new features and removals/deprecations.Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
AUTHORS
in alphabetical order;