Example #1
0
 def test_logs_other_messages_at_trace_level(self):
     logger = DummyLogger()
     log_wrapper = self._makeOne(logger)
     traces = []
     logger.trace = traces.append
     log_wrapper.log("GET /")
     self.assertEqual(len(traces), 1)
     self.assertEqual(traces[0], "GET /")
Example #2
0
 def test_logs_msgs_with_error_at_error_level(self):
     logger = DummyLogger()
     log_wrapper = self._makeOne(logger)
     errors = []
     logger.error = errors.append
     log_wrapper.log("Server Error")
     self.assertEqual(len(errors), 1)
     self.assertEqual(errors[0], "Server Error")
Example #3
0
 def test_logs_other_messages_at_trace_level(self):
     logger = DummyLogger()
     log_wrapper = self._makeOne(logger)
     traces = []
     logger.trace = traces.append
     log_wrapper.log("GET /")
     self.assertEqual(len(traces), 1)
     self.assertEqual(traces[0], "GET /")
Example #4
0
 def test_logs_msgs_with_error_at_error_level(self):
     logger = DummyLogger()
     log_wrapper = self._makeOne(logger)
     errors = []
     logger.error = errors.append
     log_wrapper.log("Server Error")
     self.assertEqual(len(errors), 1)
     self.assertEqual(errors[0], "Server Error")
Example #5
0
 def test_strips_trailing_newlines_from_msgs(self):
     logger = DummyLogger()
     log_wrapper = self._makeOne(logger)
     log_wrapper.log("foo\n")
     logdata = logger.data
     self.assertEqual(len(logdata), 1)
     self.assertEqual(logdata[0], "foo")
 def test_logging(self):
     conf = DummySocketConfig(1)
     logger = DummyLogger()
     sock_manager = self._makeOne(conf, logger=logger)
     # socket open
     sock = sock_manager.get_socket()
     self.assertEqual(len(logger.data), 1)
     self.assertEqual('Creating socket %s' % repr(conf), logger.data[0])
     # socket close
     del sock
     self.assertEqual(len(logger.data), 2)
     self.assertEqual('Closing socket %s' % repr(conf), logger.data[1])