Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « flask.testing »

Classe « Client »

Informations générales

Héritage

builtins.object
    Client

Définition

class Client(builtins.object):

Description [extrait de Client.__doc__]

This class allows you to send requests to a wrapped application.

    The use_cookies parameter indicates whether cookies should be stored and
    sent for subsequent requests. This is True by default, but passing False
    will disable this behaviour.

    If you want to request some subdomain of your application you may set
    `allow_subdomain_redirects` to `True` as if not no external redirects
    are allowed.

    .. versionchanged:: 2.0
        ``response_wrapper`` is always a subclass of
        :class:``TestResponse``.

    .. versionchanged:: 0.5
        Added the ``use_cookies`` parameter.
    

Constructeur(s)

Signature du constructeur Description
__init__(self, application: 'WSGIApplication', response_wrapper: Optional[Type[ForwardRef('Response')]] = None, use_cookies: bool = True, allow_subdomain_redirects: bool = False) -> None

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__repr__(self) -> str
delete(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``DELETE``. [extrait de delete.__doc__]
delete_cookie(self, server_name: str, key: str, path: str = '/', domain: Optional[str] = None, secure: bool = False, httponly: bool = False, samesite: Optional[str] = None) -> None Deletes a cookie in the test client. [extrait de delete_cookie.__doc__]
get(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``GET``. [extrait de get.__doc__]
head(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``HEAD``. [extrait de head.__doc__]
open(self, *args: Any, as_tuple: bool = False, buffered: bool = False, follow_redirects: bool = False, **kwargs: Any) -> 'TestResponse' Generate an environ dict from the given arguments, make a [extrait de open.__doc__]
options(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``OPTIONS``. [extrait de options.__doc__]
patch(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``PATCH``. [extrait de patch.__doc__]
post(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``POST``. [extrait de post.__doc__]
put(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``PUT``. [extrait de put.__doc__]
resolve_redirect(self, response: 'TestResponse', buffered: bool = False) -> 'TestResponse' Perform a new request to the location given by the redirect [extrait de resolve_redirect.__doc__]
run_wsgi_app(self, environ: 'WSGIEnvironment', buffered: bool = False) -> Tuple[Iterable[bytes], str, werkzeug.datastructures.Headers] Runs the wrapped WSGI app with the given environment. [extrait de run_wsgi_app.__doc__]
set_cookie(self, server_name: str, key: str, value: str = '', max_age: Union[datetime.timedelta, int, NoneType] = None, expires: Union[str, datetime.datetime, int, float, NoneType] = None, path: str = '/', domain: Optional[str] = None, secure: bool = False, httponly: bool = False, samesite: Optional[str] = None, charset: str = 'utf-8') -> None Sets a cookie in the client's cookie jar. The server name [extrait de set_cookie.__doc__]
trace(self, *args: Any, **kw: Any) -> 'TestResponse' Call :meth:`open` with ``method`` set to ``TRACE``. [extrait de trace.__doc__]

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__