Threading Testing¶
provide.testkit.threading
¶
Threading testing utilities for the provide-io ecosystem.
Fixtures and utilities for testing multi-threaded code, thread synchronization, and concurrent operations across any project that depends on provide.foundation.
Functions¶
concurrent_executor
¶
deadlock_detector
¶
mock_thread
¶
Create a mock thread for testing without actual threading.
Returns:
| Type | Description |
|---|---|
Mock
|
Mock thread object. |
Source code in provide/testkit/threading/basic_fixtures.py
test_thread
¶
test_thread() -> Callable[
[
Callable[..., Any],
tuple[Any, ...],
dict[str, Any] | None,
bool,
],
threading.Thread,
]
Create a test thread with automatic cleanup.
Returns:
| Type | Description |
|---|---|
Callable[[Callable[..., Any], tuple[Any, ...], dict[str, Any] | None, bool], Thread]
|
Function to create and manage test threads. |
Source code in provide/testkit/threading/basic_fixtures.py
thread_barrier
¶
Create a barrier for thread synchronization.
Returns:
| Type | Description |
|---|---|
Callable[[int, float | None], Barrier]
|
Function to create barriers for N threads. |
Source code in provide/testkit/threading/sync_fixtures.py
thread_condition
¶
Create condition variables for thread coordination.
Returns:
| Type | Description |
|---|---|
Callable[[Lock | None], Condition]
|
Function to create condition variables. |
Source code in provide/testkit/threading/sync_fixtures.py
thread_event
¶
Create thread events for signaling.
Returns:
| Type | Description |
|---|---|
Callable[[], Event]
|
Function to create thread events. |
Source code in provide/testkit/threading/sync_fixtures.py
thread_exception_handler
¶
thread_local_storage
¶
Create thread-local storage for testing.
Returns:
| Type | Description |
|---|---|
local
|
Thread-local storage object. |
thread_pool
¶
Create a thread pool executor for testing.
Returns:
| Type | Description |
|---|---|
ThreadPoolExecutor
|
ThreadPoolExecutor instance with automatic cleanup. |
Source code in provide/testkit/threading/basic_fixtures.py
thread_safe_counter
¶
Create a thread-safe counter.
Returns:
| Type | Description |
|---|---|
ThreadSafeCounter
|
Thread-safe counter implementation. |
thread_safe_list
¶
Create a thread-safe list for collecting results.
Returns:
| Type | Description |
|---|---|
ThreadSafeList
|
Thread-safe list implementation. |