Skip to main content

Python test runner built in Rust

Project description

rtest

PyPI version Python License: MIT

A Python test runner built with Rust.

⚠️ Development Notice: rtest is 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:

Built with Rust for the Python community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rtest-0.0.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rtest-0.0.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rtest-0.0.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

rtest-0.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rtest-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rtest-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rtest-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rtest-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file rtest-0.0.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2eff6a6e3ebc767ea0a347858708397b5e36b2c1bcc4bf686d0f3329fb84b03
MD5 a10c8e8993971bf1004e6fed4499028b
BLAKE2b-256 66086c372035377bcf482363f10e4ac72d6eecb8353532936748d73f85d7143a

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2677a3d210404e432a2e079113c86ee36b5da3cd265d0f3f1b9a34ddcca3ea4
MD5 1a27784f8e57645b79eb40211d897389
BLAKE2b-256 07dc3d664fa02eda6143838d532fa2a40876e3244612b9dffd355762d443d257

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ad93c268a1b2346b9c6ddfd5b813c94e597ac2ec7f4578ae57f7ebc7f73342c
MD5 4a914c89c30c7406bbb8caea8d15c1b8
BLAKE2b-256 90a4dafd1054553dfb78d4a24c70372fbf22c6dd9c982c1e347cacab9f07a175

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb345acd55a02e131d3a4416fca9ba4b23b3e6cec8ca9b1a1732609c6fee367f
MD5 f3d9b03c850673915b9b5f9f8e224bd9
BLAKE2b-256 8372c066b7234b65fa73984b799f635ec49f48899babe0330879c5a4fda3fbcf

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 373dfddb0a1b7a6776d5f26b4c3193ac094d14de1732d2f62565be2fbb987f5b
MD5 d66e71590a5ef414d4e7214e8666c243
BLAKE2b-256 e8841710641e859ba87966dcb6e0f111773f29f0c4d197a737fcbfe4ee5bd4de

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8904df206204705579059db2af24b3b76a730a3753955dadecf2e4d4ce71ab4b
MD5 1c5c4d0b03e127b37d54974178511d32
BLAKE2b-256 0efe342c1f5fb2990024b396cd07fca3bab933632e10e640022f629a14012d58

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 860ab62b35ec807b43c83d60686459272da5c98883df11919f0f4ffe97426c83
MD5 f05dd1eb2253ef875428e50777221445
BLAKE2b-256 a54bcfab412569e15d24814a361253ab34f814380e52597731b24e66d0299e84

See more details on using hashes here.

File details

Details for the file rtest-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rtest-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed0a6f5decd022ddfb8e546501296fe69716a7b318a2a0c1e98934c160332b8f
MD5 3686e7f0b108a30aeb7e9a24adc9ed93
BLAKE2b-256 43e5b1be362f3324cb35ae8850f1442deb71a668072640837d862d0cc6209be3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page