Esempio n. 1
0
  def test_logging_levels(self):
    old_level = logging.get_verbosity()

    logging.set_verbosity(logging.DEBUG)
    self.assertEquals(logging.get_verbosity(), logging.DEBUG)
    self.assertTrue(logging.level_debug())
    self.assertTrue(logging.level_info())
    self.assertTrue(logging.level_warning())
    self.assertTrue(logging.level_error())

    logging.set_verbosity(logging.INFO)
    self.assertEquals(logging.get_verbosity(), logging.INFO)
    self.assertFalse(logging.level_debug())
    self.assertTrue(logging.level_info())
    self.assertTrue(logging.level_warning())
    self.assertTrue(logging.level_error())

    logging.set_verbosity(logging.WARNING)
    self.assertEquals(logging.get_verbosity(), logging.WARNING)
    self.assertFalse(logging.level_debug())
    self.assertFalse(logging.level_info())
    self.assertTrue(logging.level_warning())
    self.assertTrue(logging.level_error())

    logging.set_verbosity(logging.ERROR)
    self.assertEquals(logging.get_verbosity(), logging.ERROR)
    self.assertFalse(logging.level_debug())
    self.assertFalse(logging.level_info())
    self.assertTrue(logging.level_error())

    logging.set_verbosity(old_level)
Esempio n. 2
0
    def test_logging_levels(self):
        old_level = logging.get_verbosity()

        logging.set_verbosity(logging.DEBUG)
        self.assert_(logging.get_verbosity() == logging.DEBUG)
        self.assert_(logging.level_debug())
        self.assert_(logging.level_info())
        self.assert_(logging.level_warn())
        self.assert_(logging.level_error())

        logging.set_verbosity(logging.INFO)
        self.assert_(logging.get_verbosity() == logging.INFO)
        self.assert_(not logging.level_debug())
        self.assert_(logging.level_info())
        self.assert_(logging.level_warn())
        self.assert_(logging.level_error())

        logging.set_verbosity(logging.WARN)
        self.assert_(logging.get_verbosity() == logging.WARN)
        self.assert_(not logging.level_debug())
        self.assert_(not logging.level_info())
        self.assert_(logging.level_warn())
        self.assert_(logging.level_error())

        logging.set_verbosity(logging.ERROR)
        self.assert_(logging.get_verbosity() == logging.ERROR)
        self.assert_(not logging.level_debug())
        self.assert_(not logging.level_info())
        self.assert_(not logging.level_warn())
        self.assert_(logging.level_error())

        logging.set_verbosity(old_level)