-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Changes in the logging plugin for 3.4 #3124
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5ad1313
log_cli must now be enabled explicitly
nicoddemus 8dcd271
No longer change the level of any logger unless requested explicitly
nicoddemus aca1b06
Undo log level set by caplog.set_level at the end of the test
nicoddemus 8d735f3
Live log option now writes to the terminal reporter
nicoddemus 6bb7395
Update logging docs with the new changes in 3.4
nicoddemus c53b72f
Add CHANGELOG for 3013
nicoddemus 5d89a93
Small improvements to tests suggested during review
nicoddemus 8f6a592
Add newline before log messages and enable -v output when log_cli is …
nicoddemus 97a4967
Improve code formatting
nicoddemus 4a43657
Simplify test assertions a bit
nicoddemus 9dbcac9
Suspend stdout/stderr capturing when emitting live logging messages
nicoddemus 18e0535
Use six.StringIO and __name__ in test_live_logging_suspends_capture
nicoddemus 2e40a8b
Fix test_caplog_captures_for_all_stages by setting log level
nicoddemus 27ae270
Mention in docs that log messages of level WARNING or above are captured
nicoddemus 29a7b5e
Initialize log_cli_handler to None during LoggingPlugin init
nicoddemus 0df42b4
Show a header for each testing phase during live logging
nicoddemus 3a9d0b2
Use pytest_runtest_logstart to signal the start of a new test
nicoddemus 9f4688e
Remove unnecessary -s from test_log_cli_enabled_disabled
nicoddemus 113bfb6
Report 'call' phase as 'live log call'
nicoddemus b4e8861
Fix typos
nicoddemus 2f955e0
Update documentation: rewording and move things for better reading flow
nicoddemus 15cbd61
Change caplog.get_handler(when) to caplog.get_records(when)
nicoddemus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**Incompatible change**: after community feedback the `logging <https://docs.pytest.org/en/latest/logging.html>`_ functionality has undergone some changes. Please consult the `logging documentation <https://docs.pytest.org/en/latest/logging.html#incompatible-changes-in-pytest-3-4>`_ for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
New ``caplog.get_handler(when)`` method which provides access to the underlying ``Handler`` class used to capture logging during each testing stage, allowing users to obtain the captured records during ``"setup"`` and ``"teardown"`` stages. | ||
New ``caplog.get_records(when)`` method which provides access the captured records during each testing stage: ``"setup"``, ``"call"`` and ``"teardown"`` stages. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess that a try finally block is needed here around
yield result
. Otherwise result._finalize() is not called if an exception is raised in the code called afteryield result
.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.
Your suggestion is true for
@contextmanager
, but it is not needed for pytest fixtures: the code after theyield
is always executed regardless if an exception has been raised in the test or not. 😉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.
Huh did not know that. Slick.