Parallel unit test runner with coverage support
Project description
unittest-parallel
unittest-parallel is a parallel unit test runner for Python with coverage support.
Run Unit Tests in Parallel
To run 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 unit test modules on all CPU cores available.
To run your unit 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
Parallelism Level
By default, unittest-parallel runs test modules in parallel, which works with
test class and module fixtures.
If you don't have any module fixtures, you can use the --level=class
option to run test classes in
parallel. If you don't have any module or class fixtures, you can use the --level=test
option to
run individual tests in parallel.
Do I Need unittest-parallel?
unittest-parallel helps the most when you have many long-running unit tests, such as those that make web service calls or are compute-intensive. If you just have many fast-running unit tests, unittest-parallel may slow down unit test execution due to the cost of parallelization.
For example, for one of my projects with thousands of long-running unit tests, running tests with unittest-parallel is five times faster than running tests using Python's built-in unit test runner.
For another project, with hundreds of fast-running unit tests, running tests using unittest-parallel is twice as slow as running them using Python's built-in unit test runner.
To determine if unittest-parallel will improve your unit test run times, you'll need to try it on your project.
Usage
usage: unittest-parallel [-h] [-v] [-q] [-f] [-b] [-k TESTNAMEPATTERNS]
[-s START] [-p PATTERN] [-t TOP] [-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, --start-directory START
Directory to start discovery ('.' default)
-p PATTERN, --pattern PATTERN
Pattern to match tests ('test*.py' default)
-t TOP, --top-level-directory TOP
Top level directory of project (defaults to start
directory)
parallelization options:
-j COUNT, --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
Development
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file unittest_parallel-1.6.2.tar.gz
.
File metadata
- Download URL: unittest_parallel-1.6.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0rc3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60a270d7209691fda520f169cf4112300dc2e95db47ea62a0d57a2b43e86e557 |
|
MD5 | a14dc4d4572b8342b43bc7399a2e3ed9 |
|
BLAKE2b-256 | 68ba8772090a6d7a329c0f66f18e7c1a65877368c72982b8c517973349b79491 |
File details
Details for the file unittest_parallel-1.6.2-py3-none-any.whl
.
File metadata
- Download URL: unittest_parallel-1.6.2-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0rc3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a2ab4e9668123d792655a3d1e818bfabdbee03b46e5324e13c00db5510610de |
|
MD5 | 437f5c67193c2335919d414a94b286e9 |
|
BLAKE2b-256 | 99356ad1b54463edc86346d69a88e2d380d9c684abcb50875104c71e4d72fdd6 |