Python test runner built in Rust
Project description
rtest
A Python test runner built with Rust.
⚠️ Development Notice:
rtestis in active development and not yet ready for production use. Expect bugs, incomplete features, and breaking changes as we work toward stability.
Features
Resilient Test Collection
Unlike pytest which stops execution when collection errors occur, rtest continues running tests even when some files fail to collect:
pytest stops everything when collection fails:
collected 22 items / 3 errors
!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!
============================== 1 warning, 3 errors in 0.97s ==============================
# No tests run - you're stuck
rtest keeps going:
collected 22 items / 3 errors
!!!!!!!!!!!!!!!!!! Warning: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!
================================== test session starts ===================================
# Your 22 working tests run while you fix the 3 broken files
Built-in Parallelization
rtest includes parallel test execution out of the box, without requiring additional plugins like pytest-xdist. Simply use the -n flag to run tests across multiple processes:
# Run tests in parallel (recommended for large test suites)
rtest -n 4 # Use 4 processes
rtest -n auto # Auto-detect CPU cores
rtest --maxprocesses 8 # Limit maximum processes
Current Implementation
At the current moment, rtest delegates to pytest for test execution while providing enhanced collection and parallelization features.
Performance
rtest delivers significant performance improvements over pytest:
=== Full Test Execution Benchmark ===
Benchmark 1: pytest
Time (mean ± σ): 3.990 s ± 0.059 s [User: 3.039 s, System: 0.937 s]
Range (min … max): 3.881 s … 4.113 s 20 runs
Benchmark 2: rtest
Time (mean ± σ): 65.9 ms ± 10.6 ms [User: 22.9 ms, System: 22.8 ms]
Range (min … max): 40.6 ms … 78.7 ms 20 runs
Summary
rtest ran
60.52 ± 9.78 times faster than pytest
=== Test Collection Only Benchmark ===
Benchmark 1: pytest --collect-only
Time (mean ± σ): 4.051 s ± 0.114 s [User: 3.060 s, System: 0.959 s]
Range (min … max): 3.961 s … 4.424 s 20 runs
Benchmark 2: rtest --collect-only
Time (mean ± σ): 40.7 ms ± 11.6 ms [User: 16.6 ms, System: 12.8 ms]
Range (min … max): 27.0 ms … 80.8 ms 20 runs
Summary
rtest --collect-only ran
99.61 ± 28.52 times faster than pytest --collect-only
Performance benchmarks are a work-in-progress. These results are from a typical test suite using hyperfine with 20 runs each on MacBook Pro M4 Pro (48GB RAM). More comprehensive benchmarking is on the roadmap once additional features are implemented.
Quick Start
Installation
pip install rtest
Requires Python 3.9+
Basic Usage
# Drop-in replacement for [`pytest`](https://pytest.org)
rtest
# That's it! All your existing [`pytest`](https://pytest.org) workflows work
rtest tests/
rtest tests/test_auth.py -v
rtest -- -k "test_user" --tb=short
Advanced Usage
Environment Configuration
# Set environment variables for your tests
rtest -e DEBUG=1 -e DATABASE_URL=sqlite://test.db
# Perfect for testing different configurations
rtest -e ENVIRONMENT=staging -- tests/integration/
Collection and Discovery
# See what tests would run without executing them
rtest --collect-only
# Mix `rtest` options with any [`pytest`](https://pytest.org) arguments
rtest -n 4 -- -v --tb=short -k "not slow"
Python API
from rtest import run_tests
# Programmatic test execution
run_tests()
# With custom [`pytest`](https://pytest.org) arguments
run_tests(pytest_args=["tests/unit/", "-v", "--tb=short"])
# Perfect for CI/CD pipelines and automation
result = run_tests(pytest_args=["--junitxml=results.xml"])
Command Reference
| Option | Description |
|---|---|
-n, --numprocesses N |
Run tests in N parallel processes |
--maxprocesses N |
Maximum number of worker processes |
-e, --env KEY=VALUE |
Set environment variables (can be repeated) |
--dist MODE |
Distribution mode for parallel execution (default: load) |
--collect-only |
Show what tests would run without executing them |
--help |
Show all available options |
--version |
Show rtest version |
Pro tip: Use -- to separate rtest options from pytest arguments:
rtest -n 4 -e DEBUG=1 -- -v -k "integration" --tb=short
Contributing
We welcome contributions! Check out our Contributing Guide for details on:
- Reporting bugs
- Suggesting features
- Development setup
- Documentation improvements
License
MIT - see LICENSE file for details.
Acknowledgments
This project takes inspiration from Astral and leverages their excellent Rust crates:
ruff_python_ast- Python AST utilitiesruff_python_parser- Python parser implementation
Built with Rust for the Python community
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 Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rtest-0.0.4.tar.gz.
File metadata
- Download URL: rtest-0.0.4.tar.gz
- Upload date:
- Size: 765.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e156405aa3225864dbda33c4562e9623d795d46712bd348f02df0216a065a33
|
|
| MD5 |
d0870864181cf2d3fd459cb7b17ea2c8
|
|
| BLAKE2b-256 |
b007eaa873aad149d2ce319dee504f9107532debd1c293e0c25b86d3b85ef8e1
|
File details
Details for the file rtest-0.0.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3ec2a3ebf733e4fec82dfa5590d40fadd2e7540f81a8d992ebe7148383587ed
|
|
| MD5 |
d55c5561ccc4532f1bc5fea83aaaafba
|
|
| BLAKE2b-256 |
6243efec1a0fdad9fd382b15d0bb028dd6a6314054eeabfa15d2611702939c1d
|
File details
Details for the file rtest-0.0.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a19bd8a0ae8e58aa1b9e2489a86e440529fafee8cb52582a0e4a6ff872e85e50
|
|
| MD5 |
7979ad58a8ac360f200d3fb910bd52a9
|
|
| BLAKE2b-256 |
b889f8131a487cebfbc43f5326f992e49aefbc57cee15fe1d88e2a3ab8c0d1b0
|
File details
Details for the file rtest-0.0.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdede28bf317179b957913e757bbc622d6d006a08541b65dd49c3ad24da477be
|
|
| MD5 |
6f535985eea19ff9a2ad01212bf6c078
|
|
| BLAKE2b-256 |
fb56bc62c6ad070316e8f4405359a2ebc37ccb4d86d5ef51769380c6e4b7aa84
|
File details
Details for the file rtest-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b564a22f9acede8513d90cbc5def0ccc38c098fee5dbece476f831746cdc6fd
|
|
| MD5 |
0aec486515893f7033002ec68d9b72cb
|
|
| BLAKE2b-256 |
d5c1267ed1c9e575957671e409eb59d0a97ecfc6314f6e501aec53942569ada5
|
File details
Details for the file rtest-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f522949411b62ee27e481a865fc0ae74ca33e0577038a6d4b728fe5d0dec1e80
|
|
| MD5 |
f4b1fdb98bd4a70cbb9e082d4b886132
|
|
| BLAKE2b-256 |
bdab75fa678604e83136d9339284423a504088a15d048a3304d940fdde0d74af
|
File details
Details for the file rtest-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78aa0ded96f3ec0564c406ef7a6d6630684d9abcbbd01ce60e2d2105a343b53f
|
|
| MD5 |
06e2680edb29e0610a321761f80c0815
|
|
| BLAKE2b-256 |
a803556ca0c6e36ae168f44e5340a29f9fd77cae9e07399d7c35374924edd3bf
|
File details
Details for the file rtest-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4490f3058e5546891c348193c6128d4ff5981b19f3d508e0cbf86a576763837
|
|
| MD5 |
342450376e2676a968a35a958bd08f55
|
|
| BLAKE2b-256 |
97f3fe852d513ccb3ecdc8b64c5bffb83d9ec0cd7bca5fa74f19068e4990ad67
|
File details
Details for the file rtest-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rtest-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e94771dfab32f4f05618508f440825483495c16ef943499136c8d18766cf545
|
|
| MD5 |
7b5db5bbf71612cf7544fb63064e90c2
|
|
| BLAKE2b-256 |
8f0a0da01b1bdf487eab5c7a7ed67d363aced0819f3c4c0eaa9f9b2ca8221c67
|