Python mocking logging while retaining log output
问题 I have a series of unit/integration tests which using the python logging module . I would like to test that the right things are logged when appropriate which I can achieve using the mock module as follows: @mock.patch('logging.Logger.info') However, when I do this the actual logging is stopped (for obvious reasons!) and this is useful for me to debug why my tests are working etc. My question is as follows: Is there a way in why I can mock out logging calls so I can assert they have been