Exemple #1
0
 def test_callback_exception(self):
     dto_handler = DTOHandler()
     class TestException(Exception):
         pass
     
     dto_handler._callback(signal = None, dto = TestException())
     self.assertEquals(len(dto_handler.exceptions), 1)
     self.assertTrue(isinstance(dto_handler.exceptions[0], TestException))
Exemple #2
0
 def test_callback_log_record(self):
   
     logging.basicConfig(filename = "/dev/null",
                         level=logging.DEBUG)
     logger = logging.getLogger()
     log_handler = HandlerStub()
     log_handler.setLevel(logging.DEBUG)
     
     logger.addHandler(log_handler)
     record = logging.LogRecord("unittest", logging.DEBUG, "foo", 2,
                                "bar", "baz", None)
     log_handler.expected_msg = "bar"
     dto_handler = DTOHandler()
     dto_handler._callback(signal = None, dto = record)
     logger.removeHandler(log_handler)