'How to override a log configuration in tests?

In my application, there is a log configuration coming from a file, set like this:

somefile.py

from logging.config import fileconfig
fileconfig('filename') 

But in my test cases, I would like to not have this configuration, I commented the line above to run my tests and I could run my functions and capture the logs I wanted just fine. So my question is how in my test.py file can I override this logging config? Because in production I can't just go there and comment that line. I'm kinda new to the logging, my problem looks basic, but I'm having trouble with it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source