Works like a regular Werkzeug test client but has knowledge about Flask's contexts to defer the cleanup of the request context until the end of a ``with`` block. For general information about how to use this class refer to :class:`werkzeug.test.Client`. .. versionchanged:: 0.12 `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 | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | open |
Undocumented |
Method | session |
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. |
Class Variable | application |
Undocumented |
Instance Variable | environ |
Undocumented |
Instance Variable | preserve |
Undocumented |
Method | _copy |
Undocumented |
Method | _request |
Undocumented |
Instance Variable | _context |
Undocumented |
Instance Variable | _new |
Undocumented |
t.Optional[ type]
, exc_value: t.Optional[ BaseException]
, tb: t.Optional[ TracebackType]
):
(source)
¶
Undocumented
t.Any
, buffered: bool
= False, follow_redirects: bool
= False, **kwargs: t.Any
) -> TestResponse
:
(source)
¶
Undocumented
def session_transaction(self, *args:
t.Any
, **kwargs: t.Any
) -> t.Generator[ SessionMixin, None, None]
:
(source)
¶
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 :meth:`~flask.Flask.test_request_context` which are directly passed through.