module documentation

Undocumented

Class ​Client This class allows you to send requests to a wrapped application.
Class ​Client​Redirect​Error If a redirect loop is detected when using follow_redirects=True with the :cls:`Client`, then this exception is raised.
Class ​Environ​Builder This class can be used to conveniently create a WSGI environment for testing purposes. It can be used to quickly create WSGI environments or request objects from arbitrary data.
Class ​Test​Response ~werkzeug.wrappers.Response subclass that provides extra information about requests made with the test Client.
Function create​_environ No summary
Function encode​_multipart Like stream_encode_multipart but returns a tuple in the form (boundary, data) where data is bytes.
Function run​_wsgi​_app Return a tuple in the form (app_iter, status, headers) of the application output. This works best if you pass it an application that returns an iterator all the time.
Function stream​_encode​_multipart Encode a dict of values (either strings or file descriptors or FileStorage objects.) into a multipart encoded string stored in a file descriptor.
Class _​Test​Cookie​Headers A headers adapter for cookielib
Class _​Test​Cookie​Jar A cookielib.CookieJar modified to inject and read cookie headers from and to wsgi environments, and wsgi application responses.
Class _​Test​Cookie​Response Something that looks like a httplib.HTTPResponse, but is actually just an adapter for our test responses to make them available for cookielib.
Function ​_iter​_data Iterate over a mapping that might have a list of values, yielding all key, value pairs. Almost like iter_multi_items but only allows lists, not tuples, of values so tuples can be used for files.
Variable _​TAny​Multi​Dict Undocumented
def create_environ(*args, **kwargs):

Create a new WSGI environ dict based on the values passed. The first parameter should be the path of the request which defaults to '/'. The second one can either be an absolute path (in that case the host is localhost:80) or a full path to the request with scheme, netloc port and the path to the script.

This accepts the same arguments as the EnvironBuilder constructor.

Changed in version 0.5: This function is now a thin wrapper over EnvironBuilder which was added in 0.5. The headers, environ_base, environ_overrides and charset parameters were added.
Parameters
*args:t.AnyUndocumented
**kwargs:t.AnyUndocumented
Returns
WSGIEnvironmentUndocumented
def encode_multipart(values, boundary=None, charset='utf-8'):
Like stream_encode_multipart but returns a tuple in the form (boundary, data) where data is bytes.
Parameters
values:t.Mapping[str, t.Any]Undocumented
boundary:t.Optional[str]Undocumented
charset:strUndocumented
Returns
t.Tuple[str, bytes]Undocumented
def run_wsgi_app(app, environ, buffered=False):

Return a tuple in the form (app_iter, status, headers) of the application output. This works best if you pass it an application that returns an iterator all the time.

Sometimes applications may use the write() callable returned by the start_response function. This tries to resolve such edge cases automatically. But if you don't get the expected output you should set buffered to True which enforces buffering.

If passed an invalid WSGI application the behavior of this function is undefined. Never pass non-conforming WSGI applications to this function.

Parameters
app:WSGIApplicationthe application to execute.
environ:WSGIEnvironmentUndocumented
buffered:boolset to True to enforce buffering.
Returns
t.Tuple[t.Iterable[bytes], str, Headers]tuple in the form (app_iter, status, headers)
def stream_encode_multipart(data, use_tempfile=True, threshold=1024*500, boundary=None, charset='utf-8'):
Encode a dict of values (either strings or file descriptors or FileStorage objects.) into a multipart encoded string stored in a file descriptor.
Parameters
data:t.Mapping[str, t.Any]Undocumented
use​_tempfile:boolUndocumented
threshold:intUndocumented
boundary:t.Optional[str]Undocumented
charset:strUndocumented
Returns
t.Tuple[t.IO[bytes], int, str]Undocumented
def _iter_data(data):
Iterate over a mapping that might have a list of values, yielding all key, value pairs. Almost like iter_multi_items but only allows lists, not tuples, of values so tuples can be used for files.
Parameters
data:t.Mapping[str, t.Any]Undocumented
Returns
t.Iterator[t.Tuple[str, t.Any]]Undocumented
_TAnyMultiDict =

Undocumented