Change flask.xxx to plain version in testing docs

This commit is contained in:
Frank Yu 2021-06-20 23:20:14 +08:00 committed by GitHub
parent d426b58e57
commit 35eb582bf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -225,13 +225,13 @@ temporarily. With this you can access the :class:`~flask.request`,
:class:`~flask.g` and :class:`~flask.session` objects like in view
functions. Here is a full example that demonstrates this approach::
import flask
from flask import Flask, request
app = flask.Flask(__name__)
app = Flask(__name__)
with app.test_request_context('/?name=Peter'):
assert flask.request.path == '/'
assert flask.request.args['name'] == 'Peter'
assert request.path == '/'
assert request.args['name'] == 'Peter'
All the other objects that are context bound can be used in the same
way.
@ -248,7 +248,7 @@ the test request context leaves the ``with`` block. If you do want the
:meth:`~flask.Flask.before_request` functions to be called as well, you
need to call :meth:`~flask.Flask.preprocess_request` yourself::
app = flask.Flask(__name__)
app = Flask(__name__)
with app.test_request_context('/?name=Peter'):
app.preprocess_request()
@ -261,7 +261,7 @@ If you want to call the :meth:`~flask.Flask.after_request` functions you
need to call into :meth:`~flask.Flask.process_response` which however
requires that you pass it a response object::
app = flask.Flask(__name__)
app = Flask(__name__)
with app.test_request_context('/?name=Peter'):
resp = Response('...')
@ -330,7 +330,7 @@ context around for a little longer so that additional introspection can
happen. With Flask 0.4 this is possible by using the
:meth:`~flask.Flask.test_client` with a ``with`` block::
app = flask.Flask(__name__)
app = Flask(__name__)
with app.test_client() as c:
rv = c.get('/?tequila=42')
@ -354,7 +354,7 @@ keep the context around and access :data:`flask.session`::
with app.test_client() as c:
rv = c.get('/')
assert flask.session['foo'] == 42
assert session['foo'] == 42
This however does not make it possible to also modify the session or to
access the session before a request was fired. Starting with Flask 0.8 we