werkzeug.Client

class werkzeug.Client(application, response_wrapper=None, use_cookies=True, allow_subdomain_redirects=False)[source]

This class allows to send requests to a wrapped application.

The response wrapper can be a class or factory function that takes three arguments: app_iter, status and headers. The default response wrapper just returns a tuple.

Example:

class ClientResponse(BaseResponse):
    ...

client = Client(MyApplication(), response_wrapper=ClientResponse)

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.

New in version 0.5: use_cookies is new in this version. Older versions did not provide builtin cookie support.

Methods

__init__(application[, response_wrapper, ...])
delete(*args, **kw) Like open but method is enforced to DELETE.
delete_cookie(server_name, key[, path, domain]) Deletes a cookie in the test client.
get(*args, **kw) Like open but method is enforced to GET.
head(*args, **kw) Like open but method is enforced to HEAD.
open(*args, **kwargs) Takes the same arguments as the EnvironBuilder class with some additions: You can provide a EnvironBuilder or a WSGI environment as only argument instead of the 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.
options(*args, **kw) Like open but method is enforced to OPTIONS.
patch(*args, **kw) Like open but method is enforced to PATCH.
post(*args, **kw) Like open but method is enforced to POST.
put(*args, **kw) Like open but method is enforced to PUT.
resolve_redirect(response, new_location, environ) Resolves a single redirect and triggers the request again directly on this redirect client.
run_wsgi_app(environ[, buffered]) Runs the wrapped WSGI app with the given environment.
set_cookie(server_name, key[, value, ...]) Sets a cookie in the client’s cookie jar.
trace(*args, **kw) Like open but method is enforced to TRACE.