def setup_method(self, method):
""" setup any state tied to the execution of the given method in a
class. setup_method is invoked for every test method of a class.
"""
self.journal_mock = Mock()
self.cw_mock = Mock()
self.cw_mock.CloudwatchLogger.return_value = 'hello'
self.es_mock = Mock()
self.es_mock.ElasticsearchLogger.return_value = 'bye'
modules = {
'systemdlogger.journal': self.journal_mock,
'systemdlogger.cloudwatch': self.cw_mock,
'systemdlogger.elasticsearch': self.es_mock
}
self.module_patcher = patch.dict('sys.modules', modules)
self.module_patcher.start()
from systemdlogger.runner import Runner
self.Runner = Runner
评论列表
文章目录