Configuration
Command-Line Options
--workers
Number of parallel workers for test execution.
pytest --workers 4
pytest --workers auto # Uses CPU count
Default: Plugin disabled (sequential execution)
Values:
| Value | Description |
|---|---|
N (int) |
Run with exactly N workers |
auto |
Auto-detect using os.cpu_count() |
--worker-timeout
Timeout in seconds for worker thread completion.
pytest --workers 4 --worker-timeout 300
Default: None (no timeout)
Environment Variables
PYTEST_CONCURRENCY_WORKERS
Enable parallel execution and set worker count.
export PYTEST_CONCURRENCY_WORKERS=4
pytest # Runs with 4 workers
Values: Same as --workers CLI option
PYTEST_CONCURRENCY_WORKER_TIMEOUT
Set worker timeout via environment.
export PYTEST_CONCURRENCY_WORKER_TIMEOUT=300
pytest # Workers timeout after 5 minutes
Priority
CLI options take precedence over environment variables:
--workersCLI optionPYTEST_CONCURRENCY_WORKERSenvironment variable- Plugin disabled (sequential execution)
Test Distribution
Tests are distributed using round-robin algorithm:
- All tests are sorted by
nodeid - Parametrized tests with the same
module.class.functionare grouped together - Groups are distributed across workers in round-robin fashion
This ensures:
- Balanced load across workers
- Setup/teardown consistency for parametrized tests
- Deterministic distribution (same tests always go to same worker)