Permalink
Browse files

Moved testcase for test client context binding to the TestToolsTestCase

  • Loading branch information...
1 parent 8dbd71e commit 485a6c332b1cd10495f6f3aafe2690e07f01b422 @mitsuhiko mitsuhiko committed Aug 25, 2011
Showing with 30 additions and 30 deletions.
  1. +30 −30 tests/flask_tests.py
View
@@ -153,36 +153,6 @@ def index():
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 @@ def test_session_transactions_keep_context(self):
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):

0 comments on commit 485a6c3

Please sign in to comment.