pytest caplog is incompatible with logging.config.dictConfig() #11011
-
Overview
Observations
Request
Sample code
Versions
pip listalabaster 0.7.12
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I thought I was going crazy, so I'm really glad I'm not the only one experiencing this! FWIW, this is related to a change in Python 3.9. I can run the exact same tests with the exact same requirements.txt on 3.8 and it passes. But in 3.9 and up it fails. I'm surprised this isn't a more common issue. |
Beta Was this translation helpful? Give feedback.
-
Solved it! The issue is that we had a logger called
So with this change, For us there was no reason that we needed a logger named |
Beta Was this translation helpful? Give feedback.
-
Awesome finding @erik-hasse, thanks! I will be closing this then. If somebody wants to contribute a note to the docs, it would be greatly appreciated. 🙇 |
Beta Was this translation helpful? Give feedback.
-
I will change this into a discussion, so we can mark @erik-hasse as "answer" for others with the same problem to find it more easily. 👍 |
Beta Was this translation helpful? Give feedback.
Solved it! The issue is that we had a logger called
"root"
in the config dictionary. Looking at your example you do too. In 3.8 and earlier, callinglogger.getLogger("root")
returned an otherwise ordinary logger named"root"
. But in 3.9 this change was introduced:So with this change,
caplog
is adding its handler to the root logger, but then when you calldi…