A parallel test runner for Python using subinterpreters, written in Rust.
- β‘οΈ Run all your tests in parallel
- π¬ Each test is isolated
- π Integrated coverage statistics
- π€ Works with Python 3.13
- π Automatic test discovery
- π¦ Written in Rust
xc
aims to be a fast parallel test runner for Python. It statically finds tests across all your Python files, before running each test in its own thread. Each test is executed in its own subinterpreter, which means it is independent of all other tests. Subinterpreters with separate GILs allow multiple Python interpreters to be in the same process, rather than having to start a new process for each test.
However, subinterpreters with separate GILs are only available in Python 3.12+ and many external modules (such as pydantic
) as well as some standard library modules (such as decimal
) don't support them yet.
To install xc
:
cargo install --git https://github.com/brownben/xc.git
As it is built from source, it will build against the currently active Python version. If you want it built for a specific version, make sure to build it in the virtual enviroment for that version.
To run tests:
xc # runs any tests found in the current directory
xc ./specific/folder # runs tests found in specified folder
xc ./specific/file.py # runs tests found in a specific file
xc ./a.py ./b.py # multiple paths can be specified
Tests can be in unittest
format:
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual("foo".upper(), "FOO")
Or can be in a pytest
style:
def test_add():
assert (1 + 2) == 3
Add the --coverage
flag to see coverage statistics:
ββ Coverage
β File Lines Missed Coverage
ββ .\examples\test_times.py 28 0 100.0%
ββ .\examples\simple_function.py 7 0 100.0%
ββ .\examples\skip_test.py 13 3 76.9%
ββ .\examples\invalid_method.py 9 4 55.6%
ββ .\examples\times.py 17 0 100.0%
β°ββ
This repository is licensed under the Apache-2.0 license