flask.g is now on the app context and not the request context
This commit is contained in:
parent
61d43c7f12
commit
1949c4a9ab
9 changed files with 71 additions and 20 deletions
|
|
@ -65,13 +65,13 @@ class AppContextTestCase(FlaskTestCase):
|
|||
|
||||
self.assert_equal(cleanup_stuff, [None])
|
||||
|
||||
def test_custom_request_globals_class(self):
|
||||
def test_custom_app_ctx_globals_class(self):
|
||||
class CustomRequestGlobals(object):
|
||||
def __init__(self):
|
||||
self.spam = 'eggs'
|
||||
app = flask.Flask(__name__)
|
||||
app.request_globals_class = CustomRequestGlobals
|
||||
with app.test_request_context():
|
||||
app.app_ctx_globals_class = CustomRequestGlobals
|
||||
with app.app_context():
|
||||
self.assert_equal(
|
||||
flask.render_template_string('{{ g.spam }}'), 'eggs')
|
||||
|
||||
|
|
|
|||
|
|
@ -1104,8 +1104,11 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
|||
c.get('/fail')
|
||||
|
||||
self.assert_(flask._request_ctx_stack.top is not None)
|
||||
flask._request_ctx_stack.pop()
|
||||
self.assert_(flask._app_ctx_stack.top is not None)
|
||||
# implicit appctx disappears too
|
||||
flask._request_ctx_stack.top.pop()
|
||||
self.assert_(flask._request_ctx_stack.top is None)
|
||||
self.assert_(flask._app_ctx_stack.top is None)
|
||||
|
||||
|
||||
class ContextTestCase(FlaskTestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue