Exemple #1
0
    def test_parse_loglevel_invalid(self):
        """Parsing invalid log levels returns NOTSET."""
        notset = logging.NOTSET

        self.assertEqual(parse_loglevel(''), notset)
        self.assertEqual(parse_loglevel('  '), notset)
        self.assertEqual(parse_loglevel(None), notset)
        self.assertEqual(parse_loglevel(notset), notset)
        self.assertEqual(parse_loglevel('nonexisting'), notset)
        self.assertEqual(parse_loglevel({'a': 1}), notset)
        self.assertIsNone(parse_loglevel('nonexisting', default=None))
Exemple #2
0
 def test_parse_loglevel_numeric_and_symbolic(self):
     self.assertEqual(parse_loglevel('info'), logging.INFO)
     self.assertEqual(parse_loglevel('INFO'), logging.INFO)
     self.assertEqual(parse_loglevel(logging.INFO), logging.INFO)
     self.assertEqual(parse_loglevel(str(logging.INFO)), logging.INFO)
     self.assertEqual(parse_loglevel('  %d  ' % logging.INFO), logging.INFO)