Fixtures
provide.testkit.transport.fixtures
¶
Transport and Network Testing Fixtures.
Fixtures and helpers for testing network operations, including mock servers, free port allocation, and HTTP client mocking.
Functions¶
free_port
¶
Get a free port for testing.
Returns:
| Type | Description |
|---|---|
int
|
An available port number on localhost. |
Source code in provide/testkit/transport/fixtures.py
httpx_mock_responses
¶
Pre-configured responses for HTTPX mocking.
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]]
|
Dict of common mock responses. |
Source code in provide/testkit/transport/fixtures.py
mock_dns_resolver
¶
Mock DNS resolver for testing.
Returns:
| Type | Description |
|---|---|
Mock
|
Mock resolver with resolve method. |
Source code in provide/testkit/transport/fixtures.py
mock_http_headers
¶
Common HTTP headers for testing.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dict of typical HTTP headers. |
Source code in provide/testkit/transport/fixtures.py
mock_server
¶
Create a simple mock HTTP server for testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
free_port
|
int
|
Free port number from fixture. |
required |
Yields:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with server info including url, port, and server instance. |
Source code in provide/testkit/transport/fixtures.py
mock_ssl_context
¶
Mock SSL context for testing secure connections.
Returns:
| Type | Description |
|---|---|
Mock
|
Mock SSL context with common methods. |
Source code in provide/testkit/transport/fixtures.py
mock_websocket
¶
Mock WebSocket connection for testing.
Returns:
| Type | Description |
|---|---|
Mock
|
Mock WebSocket with send, receive, close methods. |
Source code in provide/testkit/transport/fixtures.py
network_timeout
¶
tcp_client_server
¶
Create a TCP client-server pair for testing.
Yields:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with client socket, server socket, and port info. |