self.wait()
def test_malformed_first_line_response(self):
- self.stream.write(b'asdf\r\n\r\n')
- read_stream_body(self.stream, self.stop)
- start_line, headers, response = self.wait()
- self.assertEqual('HTTP/1.1', start_line.version)
- self.assertEqual(400, start_line.code)
- self.assertEqual('Bad Request', start_line.reason)
+ with ExpectLog(gen_log, '.*Malformed HTTP request line'):
+ self.stream.write(b'asdf\r\n\r\n')
+ read_stream_body(self.stream, self.stop)
+ start_line, headers, response = self.wait()
+ self.assertEqual('HTTP/1.1', start_line.version)
+ self.assertEqual(400, start_line.code)
+ self.assertEqual('Bad Request', start_line.reason)
def test_malformed_first_line_log(self):
with ExpectLog(gen_log, '.*Malformed HTTP request line'):
def __init__(self, *args, **kwargs):
# Can't use super() because logging.Filter is an old-style class in py26
logging.Filter.__init__(self, *args, **kwargs)
- self.warning_count = self.error_count = 0
+ self.info_count = self.warning_count = self.error_count = 0
def filter(self, record):
if record.levelno >= logging.ERROR:
self.error_count += 1
elif record.levelno >= logging.WARNING:
self.warning_count += 1
+ elif record.levelno >= logging.INFO:
+ self.info_count += 1
return True
try:
tornado.testing.main(**kwargs)
finally:
- # The tests should run clean; consider it a failure if they logged
- # any warnings or errors. We'd like to ban info logs too, but
- # we can't count them cleanly due to interactions with LogTrapTestCase.
- if log_counter.warning_count > 0 or log_counter.error_count > 0:
- logging.error("logged %d warnings and %d errors",
- log_counter.warning_count, log_counter.error_count)
+ # The tests should run clean; consider it a failure if they
+ # logged anything at info level or above (except for the one
+ # allowed info message "PASS")
+ if (log_counter.info_count > 1 or
+ log_counter.warning_count > 0 or
+ log_counter.error_count > 0):
+ logging.error("logged %d infos, %d warnings, and %d errors",
+ log_counter.info_count, log_counter.warning_count,
+ log_counter.error_count)
sys.exit(1)