Example #1
0
class TestCommandLineLogger(tests.BaseTest):

    def setUp(self):
        self.fakens = argparse.Namespace()
        self.logger = CommandLineLogger("foo")

    def test_setLevel(self):
        self.fakens.verbose = 0
        self.fakens.silent = False
        self.fakens.quiet = 0

        # The logger should start at 0.
        self.assertEqual(self.logger.level, 0)

        # Given the default input, it should be set to WARNING.
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.WARNING)

        # Incrementing verbose should increase the logger's verbosity.
        self.fakens.verbose = 1
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.INFO)

        # Incrementing quiet should decrease it.
        self.fakens.quiet = 1
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.WARNING)
        self.fakens.quiet = 2
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.ERROR)

        # And setting silent should shut it up completely.
        self.fakens.silent = True
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.CRITICAL)
Example #2
0
class TestCommandLineLogger(tests.BaseTest):
    def setUp(self):
        self.fakens = argparse.Namespace()
        self.logger = CommandLineLogger("foo")

    def test_setLevel(self):
        self.fakens.verbose = 0
        self.fakens.silent = False
        self.fakens.quiet = 0

        # The logger should start at 0.
        self.assertEqual(self.logger.level, 0)

        # Given the default input, it should be set to WARNING.
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.WARNING)

        # Incrementing verbose should increase the logger's verbosity.
        self.fakens.verbose = 1
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.INFO)

        # Incrementing quiet should decrease it.
        self.fakens.quiet = 1
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.WARNING)
        self.fakens.quiet = 2
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.ERROR)

        # And setting silent should shut it up completely.
        self.fakens.silent = True
        self.logger.setLevel(self.fakens)
        self.assertEqual(self.logger.level, logging.CRITICAL)
Example #3
0
 def setUp(self):
     self.fakens = argparse.Namespace()
     self.logger = CommandLineLogger("foo")
Example #4
0
 def setUp(self):
     self.fakens = argparse.Namespace()
     self.logger = CommandLineLogger("foo")