Test that we're not leaking a request context in the testsuite, fixed a leak

This commit is contained in:
Armin Ronacher 2011-08-25 15:24:10 +01:00
parent 001a5128d8
commit f051939d8b

View file

@ -96,7 +96,15 @@ def emits_module_deprecation_warning(f):
class FlaskTestCase(unittest.TestCase): class FlaskTestCase(unittest.TestCase):
pass
def ensure_clean_request_context(self):
# make sure we're not leaking a request context since we are
# testing flask internally in debug mode in a few cases
self.assertEqual(flask._request_ctx_stack.top, None)
def tearDown(self):
unittest.TestCase.tearDown(self)
self.ensure_clean_request_context()
class ContextTestCase(FlaskTestCase): class ContextTestCase(FlaskTestCase):
@ -1881,8 +1889,8 @@ class LoggingTestCase(FlaskTestCase):
@app.route('/exc') @app.route('/exc')
def exc(): def exc():
1/0 1/0
c = app.test_client()
with app.test_client() as c:
with catch_stderr() as err: with catch_stderr() as err:
c.get('/') c.get('/')
out = err.getvalue() out = err.getvalue()