diff --git a/AUTHORS b/AUTHORS index 92b0b2a1a..b5b4cc1a1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -128,6 +128,7 @@ Eric Hunsberger Eric Liu Eric Siegerman Erik Aronesty +Erik Hasse Erik M. Bray Evan Kepner Fabien Zarifian diff --git a/changelog/11011.doc.rst b/changelog/11011.doc.rst new file mode 100644 index 000000000..5faabba9c --- /dev/null +++ b/changelog/11011.doc.rst @@ -0,0 +1 @@ +Added a warning about modifying the root logger during tests when using ``caplog``. diff --git a/doc/en/how-to/logging.rst b/doc/en/how-to/logging.rst index 9957a9bb8..b9f522fa4 100644 --- a/doc/en/how-to/logging.rst +++ b/doc/en/how-to/logging.rst @@ -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`. +.. 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: