class FlaskClient(Client):
Works like a regular Werkzeug test client but has some knowledge about
how Flask works to defer the cleanup of the request context stack to the
end of a with body when used in a with statement. For general
information about how to use this class refer to
werkzeug.test.Client
.
app.test_client()
includes preset default environment, which can be
set after instantiation of the app.test_client()
object in
client.environ_base
.Basic usage is outlined in the :doc:`/testing` chapter.
Method | open |
Undocumented |
Method | session_transaction |
No summary |
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __init__ |
Undocumented |
Class Variable | application |
Undocumented |
Instance Variable | environ_base |
Undocumented |
Instance Variable | preserve_context |
Undocumented |
Undocumented
Parameters | |
*args:t.Any | Undocumented |
as_tuple:bool | Undocumented |
buffered:bool | Undocumented |
follow_redirects:bool | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
Response | Undocumented |
When used in combination with a with statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the with block is left the session is stored back.
with client.session_transaction() as session: session['value'] = 42
Internally this is implemented by going through a temporary test
request context and since session handling could depend on
request variables this function accepts the same arguments as
~flask.Flask.test_request_context
which are directly
passed through.
Parameters | |
*args:t.Any | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
t.Generator[ | Undocumented |
Undocumented
Parameters | |
exc_type:type | Undocumented |
exc_value:BaseException | Undocumented |
tb:TracebackType | Undocumented |