Change flask.xxx to plain version in testing docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Frank Yu · committed by GitHub · parent d426b58 · Browse files · 1 file·+8 added−8 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+8 added−8 removed
- other:+8 added−8 removed
Provenance
- Commit
35eb582- Tree
029a554- Author
Frank Yu <withyuxiaoy@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
d426b58
1 file changed+8 added−8 removed
modified:docs/testing.rst+8 added-8 removed
223 unmodified lines224 temporarily. With this you can access the :class:`~flask.request`,225 :class:`~flask.g` and :class:`~flask.session` objects like in view226 functions. Here is a full example that demonstrates this approach::227 228- import flask228+ from flask import Flask, request229 230- app = flask.Flask(__name__)230+ app = Flask(__name__)231 232 with app.test_request_context('/?name=Peter'):233- assert flask.request.path == '/'234- assert flask.request.args['name'] == 'Peter'233+ assert request.path == '/'234+ assert request.args['name'] == 'Peter'235 236 All the other objects that are context bound can be used in the same237 way.238 8 unmodified lines247 the test request context leaves the ``with`` block. If you do want the248 :meth:`~flask.Flask.before_request` functions to be called as well, you249 need to call :meth:`~flask.Flask.preprocess_request` yourself::250 251- app = flask.Flask(__name__)251+ app = Flask(__name__)252 253 with app.test_request_context('/?name=Peter'):254 app.preprocess_request()255 ...4 unmodified lines260 If you want to call the :meth:`~flask.Flask.after_request` functions you261 need to call into :meth:`~flask.Flask.process_response` which however262 requires that you pass it a response object::263 264- app = flask.Flask(__name__)264+ app = Flask(__name__)265 266 with app.test_request_context('/?name=Peter'):267 resp = Response('...')268 resp = app.process_response(resp)60 unmodified lines329 context around for a little longer so that additional introspection can330 happen. With Flask 0.4 this is possible by using the331 :meth:`~flask.Flask.test_client` with a ``with`` block::332 333- app = flask.Flask(__name__)333+ app = Flask(__name__)334 335 with app.test_client() as c:336 rv = c.get('/?tequila=42')337 assert request.args['tequila'] == '42'15 unmodified lines353 keep the context around and access :data:`flask.session`::354 355 with app.test_client() as c:356 rv = c.get('/')357- assert flask.session['foo'] == 42357+ assert session['foo'] == 42358 359 This however does not make it possible to also modify the session or to360 access the session before a request was fired. Starting with Flask 0.8 we361 provide a so called “session transaction” which simulates the appropriate102 unmodified lines