def test_console_entry_point_verbose2(self): argv = ['/tmp/rebuildbot/runner.py', '-vv', 'bktname'] with patch.object(sys, 'argv', argv): with patch('%s.ReBuildBot' % pbm) as mock_bot, \ patch('%s.logger' % pbm) as mock_logger, \ patch('%s.logging.Formatter' % pbm) as mock_formatter, \ patch('%s.capture_handler' % pbm) as mock_cap_handler, \ patch('%s.log_capture_string' % pbm) as mock_lcs: mock_handler = Mock() mock_handler2 = Mock() type(mock_logger).handlers = [mock_handler, mock_handler2] self.cls.console_entry_point() assert mock_bot.mock_calls == [ call('bktname', s3_prefix='rebuildbot', dry_run=False, date_check=True, run_travis=True, run_local=True, log_buffer=mock_lcs), call().run(projects=None) ] FORMAT = "[%(levelname)s %(filename)s:%(lineno)s - " \ "%(name)s.%(funcName)s() ] %(message)s" assert mock_formatter.mock_calls == [call(fmt=FORMAT)] assert mock_handler.mock_calls == [ call.setFormatter(mock_formatter.return_value) ] assert mock_handler2.mock_calls == [ call.setFormatter(mock_formatter.return_value) ] assert mock_logger.mock_calls == [ call.setLevel(logging.DEBUG) ] assert mock_cap_handler.mock_calls == [ call.setLevel(logging.DEBUG) ]
def test_set_log_level_format(self): mock_handler = Mock(spec_set=logging.Handler) with patch('%s.logger' % pbm) as mock_logger: with patch('%s.logging.Formatter' % pbm) as mock_formatter: type(mock_logger).handlers = [mock_handler] set_log_level_format(5, 'foo') assert mock_formatter.mock_calls == [call(fmt='foo')] assert mock_handler.mock_calls == [ call.setFormatter(mock_formatter.return_value) ] assert mock_logger.mock_calls == [call.setLevel(5)]
def test_set_log_level_format(self): mock_handler = Mock(spec_set=logging.Handler) with patch('%s.logger' % pbm) as mock_logger: with patch('%s.logging.Formatter' % pbm) as mock_formatter: type(mock_logger).handlers = [mock_handler] set_log_level_format(5, 'foo') assert mock_formatter.mock_calls == [ call(fmt='foo') ] assert mock_handler.mock_calls == [ call.setFormatter(mock_formatter.return_value) ] assert mock_logger.mock_calls == [ call.setLevel(5) ]
def test_set_log_level_format(self): mock_log = Mock(spec_set=logging.Logger) mock_handler = Mock(spec_set=logging.Handler) type(mock_log).handlers = [mock_handler] with patch( '%s.logging.Formatter' % pbm, autospec=True ) as mock_formatter: set_log_level_format(mock_log, 5, 'foo') assert mock_formatter.mock_calls == [ call(fmt='foo') ] assert mock_handler.mock_calls == [ call.setFormatter(mock_formatter.return_value) ] assert mock_log.mock_calls == [ call.setLevel(5) ]