Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 001a512 · Browse files · 1 file+24 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−16 removed

  • tests:+24 added−16 removed

1 file+24 added−16 removed

modified:tests/flask_tests.py+24 added-16 removed
94 unmodified lines
95 return update_wrapper(new_f, f)969798class FlaskTestCase(unittest.TestCase):99 pass99100 def ensure_clean_request_context(self):101 # make sure we're not leaking a request context since we are102 # testing flask internally in debug mode in a few cases103 self.assertEqual(flask._request_ctx_stack.top, None)104105 def tearDown(self):106 unittest.TestCase.tearDown(self)107 self.ensure_clean_request_context()108109110class ContextTestCase(FlaskTestCase):111112 def test_context_binding(self):113 app = flask.Flask(__name__)
1774 unmodified lines
18881889 @app.route('/exc')1890 def exc():1891 1/01884 c = app.test_client()18921893 with app.test_client() as c:1886 with catch_stderr() as err:1887 c.get('/')1888 out = err.getvalue()1889 assert 'WARNING in flask_tests [' in out1890 assert 'flask_tests.py' in out1891 assert 'the standard library is dead' in out1892 assert 'this is a debug statement' in out1894 with catch_stderr() as err:1895 c.get('/')1896 out = err.getvalue()1897 assert 'WARNING in flask_tests [' in out1898 assert 'flask_tests.py' in out1899 assert 'the standard library is dead' in out1900 assert 'this is a debug statement' in out19011894 with catch_stderr() as err:1895 try:1896 c.get('/exc')1897 except ZeroDivisionError:1898 pass1899 else:1900 assert False, 'debug log ate the exception'1902 with catch_stderr() as err:1903 try:1904 c.get('/exc')1905 except ZeroDivisionError:1906 pass1907 else:1908 assert False, 'debug log ate the exception'19091910 def test_exception_logging(self):1911 out = StringIO()1912 app = flask.Flask(__name__)
368 unmodified lines