Skip to content

Instantly share code, notes, and snippets.

@satiani
Created October 8, 2013 13:57
Show Gist options
  • Save satiani/6885103 to your computer and use it in GitHub Desktop.
Save satiani/6885103 to your computer and use it in GitHub Desktop.
@app.teardown_request
def shutdown_request(exc=None):
if exc is not None:
print "An exception happened!"
def test_request_teardown(self):
try:
with self.app.test_request_context():
raise Exception('dummy exception')
except:
pass
# as expected, "An exception happened!" is printed
# uncomment this to resolve the issue
# import sys; sys.exc_clear()
# now test with object updates instead of creation
with self.app.test_request_context():
# do stuff that doesn't throw an exception
# here "An exception happened!" would be printed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment