The `concurrencytest` library, currently at version 0.1.11, enables parallel execution of standard Python `unittest` test suites across multiple worker processes. It aims to speed up test execution by leveraging CPU cores. The library is actively maintained, with its latest release in March 2026, and provides mechanisms to control the number of worker processes and how tests are distributed among them.
pip install concurrencytestVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a `unittest.TestCase` and run its tests concurrently using `concurrencytest`. It shows how to load a test suite and wrap it with `ConcurrentTestSuite`, specifying the number of worker processes.
Use a Unix-like environment or consider alternative parallel testing frameworks if Windows compatibility is critical.
To preserve `setUpClass`/`tearDownClass` lifecycle semantics, explicitly use `partition_tests_by_class` when initializing `ConcurrentTestSuite`, e.g., `ConcurrentTestSuite(suite, fork_for_tests(num_workers, partition_tests_by_class))`.
Ensure each test creates its own resources and cleans them up. Avoid shared global state or use process-safe synchronization primitives (e.g., multiprocessing.Lock, Queue) if inter-process communication is absolutely necessary.
The library relies on `os.fork()`, which is not available on Windows. Run tests on Linux or macOS, or within a WSL (Windows Subsystem for Linux) environment.
Initialize `ConcurrentTestSuite` with the `partition_tests_by_class` strategy to ensure all tests from a given `TestCase` class run on the same worker process. Example: `ConcurrentTestSuite(suite, fork_for_tests(partition_func=partition_tests_by_class))`.
Review test logic for any reliance on global variables, shared file system resources, or database state that is not reset or managed in a process-safe manner between tests. Make tests entirely independent of each other's execution order or state.
No dependency data recorded yet.