from __future__ import absolute_import, division, print_function, with_statement
from tornado import gen, ioloop
-from tornado.testing import AsyncTestCase, gen_test
+from tornado.log import app_log
+from tornado.testing import AsyncTestCase, gen_test, ExpectLog
from tornado.test.util import unittest
import contextlib
self.io_loop.add_timeout(self.io_loop.time() + 0.03, self.stop)
self.wait(timeout=0.15)
+ def test_multiple_errors(self):
+ def fail(message):
+ raise Exception(message)
+ self.io_loop.add_callback(lambda: fail("error one"))
+ self.io_loop.add_callback(lambda: fail("error two"))
+ # The first error gets raised; the second gets logged.
+ with ExpectLog(app_log, "multiple unhandled exceptions"):
+ with self.assertRaises(Exception) as cm:
+ self.wait()
+ self.assertEqual(str(cm.exception), "error one")
+
class AsyncTestCaseWrapperTest(unittest.TestCase):
def test_undecorated_generator(self):
IOLoop = None
netutil = None
SimpleAsyncHTTPClient = None
-from tornado.log import gen_log
+from tornado.log import gen_log, app_log
from tornado.stack_context import ExceptionStackContext
from tornado.util import raise_exc_info, basestring_type
import functools
return IOLoop()
def _handle_exception(self, typ, value, tb):
- self.__failure = (typ, value, tb)
+ if self.__failure is None:
+ self.__failure = (typ, value, tb)
+ else:
+ app_log.error("multiple unhandled exceptions in test",
+ exc_info=(typ, value, tb))
self.stop()
return True