Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Not perfect exception handling in TestCase.__call__ #20

Open
jarus opened this Issue · 0 comments

1 participant

@jarus
Owner

In the TestCase class, there's this method:

def __call__(self, result=None):
    """
    Does the required setup, doing it here
    means you don't have to call super.setUp
    in subclasses.
    """
    try:
        self._pre_setup()
        super(TestCase, self).__call__(result)
    finally:
        self._post_teardown()

The problem is that if create_app() throws an exception when called in _pre_setup(), then the self._orig_response_class field is never set/created. And because of the exception, the 'finally' block is executed, and on line 101, _post_teardown() is trying to reference that field, and that throws another exception (saying that the field doesn't exist). So:

  1. The original exception is never reported.
  2. The user sees a completely random exception instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.