def parse_arguments(parser): """ Add default parser argument to parser, parse the arguments and set the logging level. :param obj parser: A parser object :return obj args: The parsed arguments """ parser.add_argument('--verbose', '-v', action='store_true') args = parser.parse_args() setup_logging(debug=args.verbose) return args
def test_setup_logging_returns_logger(self): ret = setup_logging(debug=True) self.assertEqual(ret, self.get_logger.return_value)
def test_setup_logging_instantiates_stream_handler_with_stdout(self): setup_logging(debug=True) self.stream_handler.assert_called_once_with(stdout)
def test_setup_logging_adds_console_handler_to_logger(self): setup_logging(debug=True) self.get_logger.return_value.addHandler.assert_called_once_with( self.stream_handler.return_value )
def test_setup_logging_sets_logging_level_to_info_by_default(self): setup_logging() self.get_logger.return_value.setLevel.assert_called_once_with(INFO)
def test_setup_logging_sets_logging_level_to_debug_if_debug_is_specified(self): setup_logging(debug=True) self.get_logger.return_value.setLevel.assert_called_once_with(DEBUG)
def test_setup_logging_gets_logger(self): setup_logging() self.get_logger.assert_called_once_with('hypernode_vagrant_runner')
def test_setup_logging_adds_console_handler_to_logger(self): setup_logging(debug=True) self.get_logger.return_value.addHandler.assert_called_once_with(self.stream_handler.return_value)
def test_setup_logging_gets_logger(self): setup_logging() self.get_logger.assert_called_once_with("hypernode_vagrant_runner")