def test_create_logger(self):
with mock.patch.object(LogConfiguration, '__init__',
return_value=None):
with mock.patch('logging.getLogger') as mock_get:
with mock.patch.object(LogConfiguration, 'file_logger'):
with mock.patch.object(LogConfiguration, 'console_logger'):
log_config = LogConfiguration('foo', 'bar')
name = 'foobar'
result = log_config.create_logger(name)
mock_get.assert_called_once_with(name)
mock_get().setLevel.assert_called_once_with(
logging.DEBUG)
mock_get().addHandler.assert_has_calls([
mock.call(log_config.file_logger),
mock.call(log_config.console_logger)
])
self.assertEqual(result, mock_get())
TestLogConfiguration.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录