pytest_httpx_recorder.recorder.base
This module provides classes and functions for recording HTTP requests and responses, and for converting HTTPX headers to a dictionary format.
- Classes:
RecordedRequest: Data class for storing details of a recorded HTTP request. RecordedResponse: Data class for storing details of a recorded HTTP response.
- Functions:
get_dict_headers(headers): Converts httpx.Headers to a standard Python dictionary.
RecordedRequest
- class pytest_httpx_recorder.recorder.base.RecordedRequest(method: str, url: str, headers: Dict[str, str], content: bytes)[source]
A data class that represents a recorded HTTP request.
- Parameters:
method (str) – The HTTP method of the request.
url (str) – The URL of the request.
headers (Dict[str, str]) – The headers of the request.
content (bytes) – The content of the request.
RecordedResponse
- class pytest_httpx_recorder.recorder.base.RecordedResponse(request: RecordedRequest, status_code: int, http_version: str, headers: Dict[str, str], content: bytes)[source]
A data class that represents a recorded HTTP response.
- Parameters:
request (RecordedRequest) – The associated RecordedRequest object.
status_code (int) – The HTTP status code of the response.
http_version (str) – The HTTP version used in the response.
headers (Dict[str, str]) – The headers of the response.
content (bytes) – The content of the response.
- Raises:
TypeError – If an incompatible type is provided for any field.
get_dict_headers
- pytest_httpx_recorder.recorder.base.get_dict_headers(headers: Headers) Dict[str, str] [source]
Converts httpx.Headers to a standard Python dictionary.
- Parameters:
headers (httpx.Headers) – The httpx.Headers object to convert.
- Return type:
Dict[str, str]
- Raises:
ValueError – If there is an issue decoding the headers.