Skip to content

Registering a root logger during a test leads to empty caplog #11618

Answered by a-recknagel
a-recknagel asked this question in Q&A
Discussion options

You must be logged in to vote

Alternatively actually clean up after yourself

I'm trying, my issue is that the call to logging.config.dictConfig has to be part of the test-code itself, and not the test setup. Maybe my example wasn't clear enough, I'm not trying to set the level in the test. Anyway, I solved the issue to a degree that is Good Enough For Me, and will share it now in case anyone stumbles over this thread:

The issue
When caplog is used in a test function, it runs some setup code which adds logging handlers (two of these, to be exact) to the root logger. It needs those in order to be able to pick up emitted logs. If the test code reconfigures the logging engine in a way that forces a re-instantiation of t…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by a-recknagel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants