OpenQuizz
Une application de gestion des contenus pédagogiques
FlaskClient Class Reference
Inheritance diagram for FlaskClient:
Collaboration diagram for FlaskClient:

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def session_transaction (self, *args, **kwargs)
 
def open (self, *args, **kwargs)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, tb)
 
- Public Member Functions inherited from Client
def __init__ (self, application, response_wrapper=None, use_cookies=True, allow_subdomain_redirects=False)
 
def set_cookie (self, server_name, key, value="", max_age=None, expires=None, path="/", domain=None, secure=None, httponly=False, samesite=None, charset="utf-8")
 
def delete_cookie (self, server_name, key, path="/", domain=None)
 
def run_wsgi_app (self, environ, buffered=False)
 
def resolve_redirect (self, response, new_location, environ, buffered=False)
 
def get (self, *args, **kw)
 
def patch (self, *args, **kw)
 
def post (self, *args, **kw)
 
def head (self, *args, **kw)
 
def put (self, *args, **kw)
 
def delete (self, *args, **kw)
 
def options (self, *args, **kw)
 
def trace (self, *args, **kw)
 
def __repr__ (self)
 

Data Fields

 environ_base
 
- Data Fields inherited from Client
 application
 
 response_wrapper
 
 cookie_jar
 
 allow_subdomain_redirects
 

Static Public Attributes

 preserve_context
 

Detailed Description

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
: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 :ref:`testing` chapter.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
args,
**  kwargs 
)

Member Function Documentation

◆ __enter__()

def __enter__ (   self)

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_value,
  tb 
)

◆ open()

def open (   self,
args,
**  kwargs 
)
Takes the same arguments as the :class:`EnvironBuilder` class with
some additions:  You can provide a :class:`EnvironBuilder` or a WSGI
environment as only argument instead of the :class:`EnvironBuilder`
arguments and two optional keyword arguments (`as_tuple`, `buffered`)
that change the type of the return value or the way the application is
executed.

.. versionchanged:: 0.5
   If a dict is provided as file in the dict for the `data` parameter
   the content type has to be called `content_type` now instead of
   `mimetype`.  This change was made for consistency with
   :class:`werkzeug.FileWrapper`.

    The `follow_redirects` parameter was added to :func:`open`.

Additional parameters:

:param as_tuple: Returns a tuple in the form ``(environ, result)``
:param buffered: Set this to True to buffer the application run.
         This will automatically close the application for
         you as well.
:param follow_redirects: Set this to True if the `Client` should
                 follow HTTP redirects.

Reimplemented from Client.

◆ session_transaction()

def session_transaction (   self,
args,
**  kwargs 
)
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.

Field Documentation

◆ environ_base

environ_base

◆ preserve_context

preserve_context
static

The documentation for this class was generated from the following file: