
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
unittest-parallel is a parallel unit test runner for Python with coverage support.
To run tests in parallel with unittest-parallel, specify the directory containing your unit tests
with the -s
argument and your package's top-level directory using the -t
argument:
unittest-parallel -t . -s tests
By default, unittest-parallel runs tests using all CPU cores.
To run tests with coverage, add either the --coverage
option (for line coverage) or the
--coverage-branch
for line and branch coverage.
unittest-parallel -t . -s tests --coverage-branch
By default, unittest-parallel runs test modules in parallel (--level=module
). Here is the list of
all parallelism options:
--level=module
- Run test modules in parallel (default)
--level=class
- Run test classes in parallel. Use this option if you have
class fixtures.
--level=test
- Run individual tests in parallel. Using this option will likely fail if you have any
class or module fixtures.
Generally speaking, unittest-parallel will run your unit tests faster by a factor of the number of
CPU cores you have, as compared to unittest discover
.
In other words, if you have 4 CPU cores, unittest-parallel will run your tests 4 times faster. If you have 8 CPU cores, it will run 8 times faster, and so on.
Note that you may see less benefit from unittest-parallel if your average test duration is short compared to the underlying cost of parallelization.
If your tests are I/O-bound (e.g., call web services), you may benefit from using a higher number of
test processes (-j
). In the following case, the I/O-bound tests run 100 times faster.
unittest-parallel -j 100 -t . -s tests
I wrote unittest-parallel for a large production backend API application with thousands of unit
tests. As expected, unittest-parallel ran tests 4 times faster using 4 cores, compared to unittest discover
.
A user reports that their tests ran 20 times faster on their development machine and 6 times faster on their test machine.
Another user reports that "it shaved 70% off the runtime of my painfully long integration tests."
Another user reports that "tests take 2x less times to run."
usage: unittest-parallel [-h] [-v] [-q] [-f] [-b] [-k TESTNAMEPATTERNS]
[-s START] [-p PATTERN] [-t TOP] [--runner RUNNER]
[--result RESULT] [-j COUNT]
[--level {module,class,test}]
[--disable-process-pooling] [--coverage]
[--coverage-branch] [--coverage-rcfile RCFILE]
[--coverage-include PAT] [--coverage-omit PAT]
[--coverage-source SRC] [--coverage-html DIR]
[--coverage-xml FILE] [--coverage-fail-under MIN]
options:
-h, --help show this help message and exit
-v, --verbose Verbose output
-q, --quiet Quiet output
-f, --failfast Stop on first fail or error
-b, --buffer Buffer stdout and stderr during tests
-k TESTNAMEPATTERNS Only run tests which match the given substring
-s, --start-directory START
Directory to start discovery ('.' default)
-p, --pattern PATTERN
Pattern to match tests ('test*.py' default)
-t, --top-level-directory TOP
Top level directory of project (defaults to start
directory)
--runner RUNNER Custom unittest runner class <module>.<class>
--result RESULT Custom unittest result class <module>.<class>
parallelization options:
-j, --jobs COUNT The number of test processes (default is 0, all cores)
--level {module,class,test}
Set the test parallelism level (default is 'module')
--disable-process-pooling
Do not reuse processes used to run test suites
coverage options:
--coverage Run tests with coverage
--coverage-branch Run tests with branch coverage
--coverage-rcfile RCFILE
Specify coverage configuration file
--coverage-include PAT
Include only files matching one of these patterns.
Accepts shell-style (quoted) wildcards.
--coverage-omit PAT Omit files matching one of these patterns. Accepts
shell-style (quoted) wildcards.
--coverage-source SRC
A list of packages or directories of code to be
measured
--coverage-html DIR Generate coverage HTML report
--coverage-xml FILE Generate coverage XML report
--coverage-fail-under MIN
Fail if coverage percentage under min
This package is developed using python-build. It was started using python-template as follows:
template-specialize python-template/template/ unittest-parallel/ -k package unittest-parallel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k noapi 1
FAQs
Parallel unit test runner with coverage support
We found that unittest-parallel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.