Exemplo n.º 1
0
 def test_message_format_can_be_set(self):
     from gocept.logging import ArgumentParser
     parser = ArgumentParser()
     parser.LOG_FORMAT = new_format = 'foo! %(messsage)s'
     with mock.patch('logging.basicConfig') as basicConfig:
         parser.parse_args([])
         basicConfig.assert_called_with(level=mock.ANY, format=new_format)
Exemplo n.º 2
0
 def test_DEBUG_if_more_verbose(self):
     from gocept.logging import ArgumentParser
     parser = ArgumentParser()
     with mock.patch('gocept.logging.argumentparser.ArgumentParser.'
                     'setup_logging') as setup_logging:
         options = parser.parse_args(['-vv'])
         self.assertEqual(options.quiet, 0)
         self.assertEqual(options.verbose, 2)
         setup_logging.assert_called_with('DEBUG')
Exemplo n.º 3
0
 def test_WARNING_by_default(self):
     from gocept.logging import ArgumentParser
     parser = ArgumentParser()
     with mock.patch('gocept.logging.argumentparser.ArgumentParser.'
                     'setup_logging') as setup_logging:
         options = parser.parse_args([])
         self.assertEqual(options.quiet, 0)
         self.assertEqual(options.verbose, 0)
         setup_logging.assert_called_with('WARNING')
Exemplo n.º 4
0
 def test_CRITICAL_if_more_quiet(self):
     from gocept.logging import ArgumentParser
     parser = ArgumentParser()
     with mock.patch('gocept.logging.argumentparser.ArgumentParser.'
                     'setup_logging') as setup_logging:
         options = parser.parse_args(['-qq'])
         self.assertEqual(options.quiet, 2)
         self.assertEqual(options.verbose, 0)
         setup_logging.assert_called_with('CRITICAL')
Exemplo n.º 5
0
 def test_argumentparser__ArgumentParser__parse_args__1(self):
     """`parse_args()` stores the computed `log_level` on options."""
     from gocept.logging import ArgumentParser
     parser = ArgumentParser()
     options = parser.parse_args(['-v'])
     self.assertEqual(options.log_level, 'INFO')
Exemplo n.º 6
0
 def test_adds_quiet_and_verbose_arguments_per_default(self):
     from gocept.logging import ArgumentParser
     parser = ArgumentParser()
     destinations = [a.dest for a in parser._actions]
     self.assertIn('quiet', destinations)
     self.assertIn('verbose', destinations)