def test_setup_logging_helper_with_merge_config(self): _setup_logging( filename=None, stream=Mock(), logging_config={'merge': True, 'foo': 1}, ) self.logging.config.dictConfig.assert_called_once_with(ANY)
def test_setup_logging_helper_with_stream(self): mock_handler = Mock() _setup_logging( filename=None, stream=Mock(), loghandlers=[mock_handler], ) self.logging.config.dictConfig.assert_called_once_with(ANY) self.logging.root.handlers.extend.assert_called_once_with( [mock_handler])
def test_setup_logging_helper_no_merge_config(self): _setup_logging( logging_config={'merge': False, 'foo': 1}, ) self.logging.config.dictConfig.assert_called_once_with(ANY)
def test_setup_logging_helper_with_stream_no_handlers(self): _setup_logging(stream=Mock()) self.logging.config.dictConfig.assert_called_once_with(ANY)
def test_setup_logging_helper_with_filename(self): _setup_logging(filename='TEMP') self.logging.config.dictConfig.assert_called_once_with(ANY)
def test_setup_logging_helper_both_filename_and_stream(self): with pytest.raises(AssertionError): _setup_logging(filename='TEMP', stream=Mock())
def test_setup_logging_helper_with_stream(self): mock_handler = Mock() logging._setup_logging(stream=Mock(), handlers=[mock_handler]) self.logging.basicConfig.assert_called_once_with( handlers=[mock_handler, self.colorlog.StreamHandler()])
def test_setup_logging_helper_with_stream_no_handlers(self): logging._setup_logging(stream=Mock()) self.logging.basicConfig.assert_called_once_with( handlers=[self.colorlog.StreamHandler()])
def test_setup_logging_helper_with_filename(self): logging._setup_logging(filename="TEMP") self.logging.basicConfig.assert_called_once_with(filename="TEMP")