From 485a6c332b1cd10495f6f3aafe2690e07f01b422 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 25 Aug 2011 20:49:53 +0100 Subject: [PATCH] Moved testcase for test client context binding to the TestToolsTestCase --- tests/flask_tests.py | 60 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/flask_tests.py b/tests/flask_tests.py index 040ddfaa..1d9daf83 100644 --- a/tests/flask_tests.py +++ b/tests/flask_tests.py @@ -153,36 +153,6 @@ class ContextTestCase(FlaskTestCase): else: assert 0, 'expected runtime error' - def test_test_client_context_binding(self): - app = flask.Flask(__name__) - @app.route('/') - def index(): - flask.g.value = 42 - return 'Hello World!' - - @app.route('/other') - def other(): - 1/0 - - with app.test_client() as c: - resp = c.get('/') - assert flask.g.value == 42 - assert resp.data == 'Hello World!' - assert resp.status_code == 200 - - resp = c.get('/other') - assert not hasattr(flask.g, 'value') - assert 'Internal Server Error' in resp.data - assert resp.status_code == 500 - flask.g.value = 23 - - try: - flask.g.value - except (AttributeError, RuntimeError): - pass - else: - raise AssertionError('some kind of exception expected') - class BasicFunctionalityTestCase(FlaskTestCase): @@ -1111,6 +1081,36 @@ class TestToolsTestCase(FlaskTestCase): with c.session_transaction(): self.assert_(req is flask.request._get_current_object()) + def test_test_client_context_binding(self): + app = flask.Flask(__name__) + @app.route('/') + def index(): + flask.g.value = 42 + return 'Hello World!' + + @app.route('/other') + def other(): + 1/0 + + with app.test_client() as c: + resp = c.get('/') + assert flask.g.value == 42 + assert resp.data == 'Hello World!' + assert resp.status_code == 200 + + resp = c.get('/other') + assert not hasattr(flask.g, 'value') + assert 'Internal Server Error' in resp.data + assert resp.status_code == 500 + flask.g.value = 23 + + try: + flask.g.value + except (AttributeError, RuntimeError): + pass + else: + raise AssertionError('some kind of exception expected') + class InstanceTestCase(FlaskTestCase):