How to override pytest logging behaviour #12035
Unanswered
mohit2152sharma
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created a custom logging class and I am trying to write tests for it. The class has it's own formatter, for example something like
"timestamp:%(asctime)s - logger_name:%(name)s - levelname:%(levelname)s - message:%(message)s"
.When i run the pytests, somehow the logs generated by this custom logger are captured in
caplog
withbasicConfig
format and on thestdout
I can see the logs in the format set by custom logging class.Following are the code snippets of how I am doing it:
How can I redirect the output of my custom logger to
"Captured log call"
?Beta Was this translation helpful? Give feedback.
All reactions