Context preserving is now part of Flask and not the test client. This fixes #326
This commit is contained in:
parent
d2eefe25e7
commit
c6316132b1
5 changed files with 64 additions and 21 deletions
|
|
@ -904,6 +904,23 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
|||
self.assertEqual(c.get('/bar/').data, 'bar')
|
||||
self.assertEqual(c.get('/bar/123').data, '123')
|
||||
|
||||
def test_preserve_only_once(self):
|
||||
app = flask.Flask(__name__)
|
||||
app.debug = True
|
||||
|
||||
@app.route('/fail')
|
||||
def fail_func():
|
||||
1/0
|
||||
|
||||
c = app.test_client()
|
||||
for x in xrange(3):
|
||||
with self.assert_raises(ZeroDivisionError):
|
||||
c.get('/fail')
|
||||
|
||||
self.assert_(flask._request_ctx_stack.top is not None)
|
||||
flask._request_ctx_stack.pop()
|
||||
self.assert_(flask._request_ctx_stack.top is None)
|
||||
|
||||
|
||||
class ContextTestCase(FlaskTestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue