Skip to main content

Python test runner built in Rust

Project description

rtest

PyPI version Python License: MIT

A high-performance Python test runner built with Rust, designed as a drop-in replacement for pytest with enhanced collection resilience and built-in parallelization.

⚠️ Development Status: This project is in early development (v0.0.x). While functional, expect breaking changes and evolving features 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 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

The current implementation focuses on enhanced test collection and parallelization, with test execution delegated to pytest for maximum compatibility.

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 shown are preliminary results from a specific test suite using hyperfine with 20 runs each on MacBook Pro M4 Pro (48GB RAM). Results may vary significantly depending on test suite characteristics, system configuration, and workload. More comprehensive benchmarking across diverse scenarios is planned.

Quick Start

Installation

pip install rtest

Requires Python 3.9+

Basic Usage

# Drop-in replacement for pytest
rtest

# That's it! All your existing pytest 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

# Useful 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 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 arguments
run_tests(pytest_args=["tests/unit/", "-v", "--tb=short"])

# Suitable 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 Distribution

rtest-0.0.6.tar.gz (778.2 kB view details)

Uploaded Source

Built Distributions

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

rtest-0.0.6-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.6-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.6-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.6-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.6-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.6-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.6-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.6-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.6.tar.gz.

File metadata

  • Download URL: rtest-0.0.6.tar.gz
  • Upload date:
  • Size: 778.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rtest-0.0.6.tar.gz
Algorithm Hash digest
SHA256 15e8c250099189fad238f4424a331fae90f258ef28b8e744e49a1ef762421ccf
MD5 89b28f9f8f260f5950f5529219660972
BLAKE2b-256 d0c10b02c9678126f4fc2fca7c254abeeb8c972f3df1e792a87d3fa86eb3909e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ff9356e250854f8d45e0015a1a1f24477222ea864a1f5aa269265f4049a7803
MD5 639c95d4ede242b2cdcd4d91d0515622
BLAKE2b-256 f96a197ae3674dc2a795770ce586f93fe3730603caad1186bc28f74a85447275

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb98cfaffe0dabd2c0957d2028e75ca66baba2c9ca2c37f3b25d7526f82b0d03
MD5 43f8215cb633c0153c118d2f550dc1a9
BLAKE2b-256 691fe1be775eef78a11cf1d421130540ac55ea0be39f8605ceb27c17026ce2ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9da26ad60558d9b1bb0bbb98bb0c4248676294d18eb1f2b0f56f44f5bd4b801f
MD5 f78d59bb8edb85ce7a5d44947ee24a89
BLAKE2b-256 cf22f8e10c1b4bf4045a4b4278a5ec9a37df6c30dc524d02662fab923b3330dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35bd83628d47fe59a6a4bae6932657b0f9fcc83075379cc70c9ca695b1db5012
MD5 748de00f1fc150341003aa03ee6559cb
BLAKE2b-256 520845d27a0e91efa8d6e8864060c6ca61f265962dd9b6226a13dd28abde9572

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b986ed3eafe39dcc8b86fcaa7609f35d42b5516a51e7fcf90b5afbf4d1c759c
MD5 ac2cc4132f29e7d77e3d628a76bb4cc1
BLAKE2b-256 406a7db39c6620b9b1d039c4f389663dfb738267414770b573fcc1db75d26260

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 04eef9063bc8ec480afcd91ea661c3fa5192ee56131ab66299bc8b10d22cce60
MD5 f05296d5163b54de843683a435b86506
BLAKE2b-256 2e813cdaf8fdead560eefa051381aa64fa4c8f8354cd30e39ce4477c6fadc194

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7030ba1eec81c6fdbfefca7ed4adf50b380fb243476e5fba5969add4cb99e7c9
MD5 3da146d97846fb0a14353c5ef02605a2
BLAKE2b-256 70d04af0d020b8f630426037a1954adaa6c340c8d52a057788745a1894327ec0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rtest-0.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ed2fda07f80a47630d32bb799f65b48aa65f2b7b26e22a3e3f1ab84e70cbb2e
MD5 255072e00f7c4dae5578498ebe442da4
BLAKE2b-256 b57fc7fc7b041c18bb24981a4958a464620f5bd7bbe782b6962c810eefcb8e3c

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