tornadoweb / tornado

Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
http://www.tornadoweb.org/
Apache License 2.0
21.7k stars 5.5k forks source link

tornado.testing can swallow exceptions #466

Closed dwt closed 12 years ago

dwt commented 12 years ago

I've just lost a whole day until I figured out why my test suite suddenly exploded completely.

Here's what happened:

Here's a reduction that nicely demonstrates the problem for me.

import unittest
import logging
from tornado.testing import AsyncTestCase

class Test(AsyncTestCase):

    def test(self):
        class FaultingException(Exception):
            def __str__(self):
                raise TypeError()
        # comment the next line to see it dying normaly
        logging.warn('baz to logging.warn')
        raise FaultingException()

# Run with $ nosetests test.py
# watch it die without reporting the exception
dwt commented 12 years ago

Corresponding issue in nose tests: https://github.com/nose-devs/nose/issues/443

bdarnell commented 12 years ago

This looks like a nose problem (at least in this reduction). I took your test case and added a call to unittest.main() at the end, and when run directly it fails as expected.

dwt commented 12 years ago

This is correct, it fails badly in the interaction with nose, as nose has a wrapper around the unittest plugins that catches the error too, but is disabled by tornado.testing.

That is why I have reported the Issue on both sides.