Index
provide.testkit.process
¶
Process and async testing fixtures for the provide-io ecosystem.
Standard fixtures for testing async code, subprocess operations, and event loop management across any project that depends on provide.foundation.
Functions¶
async_condition_waiter
¶
Helper for waiting on async conditions in tests.
Returns:
| Type | Description |
|---|---|
Callable[[Callable[[], bool], float, float], Awaitable[bool]]
|
Function to wait for conditions with timeout. |
Source code in provide/testkit/process/async_fixtures.py
async_context_manager
async
¶
Factory for creating mock async context managers.
Returns:
| Type | Description |
|---|---|
Callable[[Any | None, Any | None], AsyncMock]
|
Function that creates configured async context manager mocks. |
Source code in provide/testkit/process/async_fixtures.py
async_gather_helper
¶
Helper for testing asyncio.gather operations.
Returns:
| Type | Description |
|---|---|
Callable[..., Awaitable[list[Any]]]
|
Function to gather async results with error handling. |
Source code in provide/testkit/process/async_fixtures.py
async_iterator
async
¶
Factory for creating mock async iterators.
Returns:
| Type | Description |
|---|---|
Callable[[Sequence[T]], AsyncIterable[T]]
|
Function that creates async iterator mocks with specified values. |
Source code in provide/testkit/process/async_fixtures.py
async_lock
async
¶
Create an async lock for testing synchronization.
Returns:
| Type | Description |
|---|---|
Lock
|
asyncio.Lock instance for testing. |
async_mock_server
¶
Create a mock async server for testing.
Returns:
| Type | Description |
|---|---|
AsyncMockServer
|
Mock server with async methods. |
async_pipeline
¶
Create an async pipeline for testing data flow.
Returns:
| Type | Description |
|---|---|
AsyncPipeline
|
AsyncPipeline instance for chaining async operations. |
async_queue
¶
async_rate_limiter
¶
Create an async rate limiter for testing.
Returns:
| Type | Description |
|---|---|
AsyncRateLimiter
|
AsyncRateLimiter instance for controlling request rates. |
async_stream_reader
async
¶
Mock async stream reader for subprocess stdout/stderr.
Returns:
| Type | Description |
|---|---|
AsyncMock
|
AsyncMock configured as a stream reader. |
Source code in provide/testkit/process/subprocess_fixtures.py
async_subprocess
¶
Create mock async subprocess for testing.
Returns:
| Type | Description |
|---|---|
Callable[[int, bytes, bytes, int], AsyncMock]
|
Function that creates mock subprocess with configurable behavior. |
Source code in provide/testkit/process/subprocess_fixtures.py
async_task_group
¶
Manage a group of async tasks with cleanup.
Returns:
| Type | Description |
|---|---|
AsyncTaskGroup
|
AsyncTaskGroup instance for managing tasks. |
async_test_client
¶
Create an async HTTP test client.
Returns:
| Type | Description |
|---|---|
AsyncTestClient
|
Mock async HTTP client for testing. |
async_timeout
¶
Provide configurable timeout wrapper for async operations.
Returns:
| Type | Description |
|---|---|
Callable[[Awaitable[T], float], Awaitable[T]]
|
A function that wraps async operations with a timeout. |
Source code in provide/testkit/process/async_fixtures.py
clean_event_loop
async
¶
Ensure clean event loop for async tests.
Cancels all pending tasks after the test to prevent event loop issues.
Yields:
| Type | Description |
|---|---|
AsyncGenerator[None, None]
|
None - fixture for test setup/teardown. |
Source code in provide/testkit/process/async_fixtures.py
disable_setproctitle
¶
Disables setproctitle during tests to prevent pytest-xdist performance issues.
The setproctitle module causes severe performance degradation when running tests with pytest-xdist parallelization: - Immediate slowdown on test start - Progressive performance degradation over time - High CPU usage due to frequent system calls
Mocks setproctitle as a no-op during regular test runs while preserving functionality for mutation testing tools like mutmut that use it for displaying progress information.
Autouse and session-scoped - applies automatically to all tests in a session.
Yields:
| Name | Type | Description |
|---|---|---|
None |
None
|
Context manager for test execution with setproctitle disabled |
Note
Only disables setproctitle when NOT running under mutmut. Mutmut detection uses sys.argv to check for "mutmut" in arguments.
Source code in provide/testkit/process/system_fixtures.py
event_loop_policy
¶
Set event loop policy for tests to avoid conflicts.
Returns:
| Type | Description |
|---|---|
None
|
New event loop policy for isolated testing. |
Source code in provide/testkit/process/async_fixtures.py
mock_async_process
¶
Mock async subprocess for testing.
Returns:
| Type | Description |
|---|---|
AsyncMock
|
AsyncMock configured as a subprocess with common attributes. |