Merge pull request #11017 from erik-hasse/caplog-root-logger-docs

add a warning about modifying the root logger during tests
This commit is contained in:
Ran Benita 2023-06-28 09:28:46 +03:00 committed by GitHub
commit 81cfb3fc87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -129,6 +129,7 @@ Eric Hunsberger
Eric Liu Eric Liu
Eric Siegerman Eric Siegerman
Erik Aronesty Erik Aronesty
Erik Hasse
Erik M. Bray Erik M. Bray
Evan Kepner Evan Kepner
Evgeny Seliverstov Evgeny Seliverstov

1
changelog/11011.doc.rst Normal file
View File

@ -0,0 +1 @@
Added a warning about modifying the root logger during tests when using ``caplog``.

View File

@ -172,6 +172,13 @@ the records for the ``setup`` and ``call`` stages during teardown like so:
The full API is available at :class:`pytest.LogCaptureFixture`. The full API is available at :class:`pytest.LogCaptureFixture`.
.. warning::
The ``caplog`` fixture adds a handler to the root logger to capture logs. If the root logger is
modified during a test, for example with ``logging.config.dictConfig``, this handler may be
removed and cause no logs to be captured. To avoid this, ensure that any root logger configuration
only adds to the existing handlers.
.. _live_logs: .. _live_logs: