Пример #1
0
    def test_error(self, mocker):
        log = Logger()

        log.set_quiet(True)
        log.set_verbose(False)
        log.error("test")
        sys.stderr.write.assert_called_once()
Пример #2
0
    def test_info(self, mocker):
        log = Logger()

        log.set_quiet(True)
        self.assertTrue(log._quiet)
        self.assertFalse(log._verbose)

        log.info("test")
        sys.stderr.write.assert_not_called()

        log.set_quiet(False)
        self.assertFalse(log._quiet)
        self.assertFalse(log._verbose)

        log.info("test")
        sys.stderr.write.assert_called_once()
Пример #3
0
    def test_init_logger(self):
        log = Logger()

        self.assertEquals(log._process, sys.argv[0])
        self.assertFalse(log._quiet)
        self.assertFalse(log._verbose)

        init_logger("test", True, True, log)

        self.assertEquals(log._process, "test")
        self.assertTrue(log._quiet)
        self.assertTrue(log._verbose)
Пример #4
0
    def test_set_verbose(self):
        log = Logger()
        self.assertFalse(log._quiet)
        self.assertFalse(log._verbose)

        log.set_verbose(True)
        self.assertFalse(log._quiet)
        self.assertTrue(log._verbose)

        log.set_verbose(False)
        self.assertFalse(log._quiet)
        self.assertFalse(log._verbose)
Пример #5
0
 def test_set_process_name(self):
     log = Logger()
     self.assertEquals(log._process, sys.argv[0])
     log.set_process_name(PROCESS_NAME)
     self.assertEquals(log._process, PROCESS_NAME)
Пример #6
0
 def test_default_values(self):
     log = Logger()
     self.assertEquals(log._process, sys.argv[0])
     self.assertFalse(log._quiet)
     self.assertFalse(log._verbose)