quart.testing.utils module#

quart.testing.utils.make_test_body_with_headers(*, data: Optional[AnyStr] = None, form: Optional[dict] = None, files: Optional[Dict[str, FileStorage]] = None, json: Any = <object object>, app: Optional['Quart'] = None) Tuple[bytes, Headers]#

Make the body bytes with associated headers.

Parameters:
  • data – Raw data to send in the request body.

  • form – Key value paired data to send form encoded in the request body.

  • files – Key FileStorage paired data to send as file encoded in the request body.

  • json – Data to send json encoded in the request body.

quart.testing.utils.make_test_headers_path_and_query_string(app: Quart, path: str, headers: Optional[Union[dict, Headers]] = None, query_string: Optional[dict] = None, auth: Optional[Union[Authorization, Tuple[str, str]]] = None) Tuple[Headers, str, bytes]#

Make the headers and path with defaults for testing.

Parameters:
  • app – The application to test against.

  • path – The path to request. If the query_string argument is not defined this argument will be partitioned on a ‘?’ with the following part being considered the query_string.

  • headers – Initial headers to send.

  • query_string – To send as a dictionary, alternatively the query_string can be determined from the path.

quart.testing.utils.make_test_scope(type_: Literal['http'], path: str, method: str, headers: Headers, query_string: bytes, scheme: str, root_path: str, http_version: str, scope_base: Optional[dict], *, _preserve_context: bool = False) HTTPScope#
quart.testing.utils.make_test_scope(type_: Literal['websocket'], path: str, method: str, headers: Headers, query_string: bytes, scheme: str, root_path: str, http_version: str, scope_base: Optional[dict], *, _preserve_context: bool = False) WebsocketScope
async quart.testing.utils.no_op_push(path: str, headers: Headers) None#

A push promise sender that does nothing.

This is best used when creating Request instances for testing outside of the QuartClient. The Request instance must know what to do with push promises, and this gives it the option of doing nothing.