Skip to main content

A fast, drop-in compatible pytest runner written in Rust

Project description

pytest-rs

pytest-rs is a re-implementation of the popular Python testing framework pytest in Rust, focused on speed: a drop-in compatible runner where startup, collection, fixture orchestration, coverage measurement, and reporting are native code, while test bodies run on embedded CPython.

Note: This project is currently in active development (alpha stage). Many features are still under implementation and subject to change. See docs/DESIGN.md for the architecture and roadmap.

pytest-rs is an independent project, not affiliated with or endorsed by the pytest project.

Installation

Prebuilt wheels are published to PyPI for Linux (x86_64 / aarch64) and macOS (arm64) on CPython 3.13 / 3.14:

uv add --dev pytest-rs    # or: pip install pytest-rs

Then run your existing suite, no changes needed:

pytest-rs                       # whole suite, like `pytest`
pytest-rs tests/test_foo.py     # one file
pytest-rs -n 4                  # parallel workers (pytest-xdist compatible)
pytest-rs --cov=mypkg           # native coverage (pytest-cov compatible)

pytest-rs reads the same configuration pytest does (pytest.ini, pyproject.toml [tool.pytest] / [tool.pytest.ini_options], tox.ini, setup.cfg) and understands the familiar flags (-v, -x, -k, -m, --lf, --tb=..., -p no:NAME, ...). It installs alongside pytest without conflict — the pytest command is untouched.

Requirements

  • Linux or macOS (no Windows support yet)
  • CPython 3.13+ built with a shared libpython — true for uv-managed Pythons, python.org installers, Homebrew, conda, and distro packages. Plain pyenv builds need PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install ....

Bundled plugins

The compatibility layers for pytest-asyncio, anyio's pytest plugin, pytest-mock, pytest-cov, pytest-split, pytest-benchmark and pytest-xdist-style -n parallelism are built in — no separate plugin installs (the anyio layer runs tests through the installed anyio library's backends, so anyio itself must be in the environment as usual). Two ways to turn features off:

Per project or per run, like pytest (works with the prebuilt wheel):

[tool.pytest.ini_options]
addopts = "-p no:benchmark -p no:split"

At build time, when installing from source — bundled plugins are Cargo features, all enabled by default:

[tool.uv]
config-settings-package = { pytest-rs = { build-args = "--no-default-features --features asyncio,mock" } }

Third-party plugins (not reimplemented, loaded as-is)

Installed pytest11 entry points load through the pytest API shim — plugins pytest-rs does not reimplement can still work as-is. The supported surface includes fixtures, markers, pytest_addoption (plugin --flags and ini options), config.stash, custom hookspecs (pytest_addhooks), pytest_runtest_protocol/pytest_runtest_call hookwrappers, and terminal-reporter replacement (a plugin that unregisters the terminalreporter plugin and registers its own subclass takes over the output — pytest-rs suppresses its native rendering and drives the replacement through the same hooks pluggy would). Spot-verified status:

status plugins
works — upstream test suite gates CI pytest-timeout (40/41, see conformance below); anyio's own plugin module also loads this way
works — plugin-smoke gates CI (functional demos, conformance/plugin_smoke.py) Faker, time-machine, requests-mock, pytest-randomly (test reordering + seed header), inline-snapshot (snapshot assertions + --inline-snapshot flag), pytest-run-parallel (--parallel-threads really runs each test on N threads)
works — plugin-smoke gates CI (terminal output byte-diffed against real pytest 9.0.3) pytest-pretty, pytest-sugar (progress bar, instant failures; activates on a tty or --force-sugar) — reporter replacement
not working yet pytest-env — needs the pytest_load_initial_conftests early hook

A plugin that fails to import (e.g. it reaches into pytest/pluggy internals the shim doesn't provide) warns and is skipped without breaking the run. -p no:NAME and PYTEST_DISABLE_PLUGIN_AUTOLOAD opt out, like pytest.

Performance

Native startup, collection, fixture orchestration, parallel workers (fork-based) and coverage measurement. Where it pays off:

  • suites with heavy fixture/parametrize orchestration and large collections
  • --cov runs (a native collector instead of a tracing hook)
  • -n parallel runs (fork workers instead of spawned interpreters)

For small, CPU-bound suites the test bodies dominate and pytest-rs runs at parity with pytest. Try it on your own suite:

hyperfine -w 1 'pytest -q' 'pytest-rs'

Known limitations

  • unix only (no Windows)
  • no --pdb / debugger integration yet
  • third-party pytest plugins are loaded via the pytest11 entry point and the pytest API shim; plugins reaching deep into pytest internals may not work (see "Third-party plugins" above for verified examples)

Conformance testing

Compatibility is verified by running the upstream test suites of the libraries pytest-rs reproduces, unchanged, under pytest-rs (conformance/).

Current results (total = passed + failed + errors + skipped; updated automatically by conformance/runner.py, refreshed by CI on every push to main — see conformance/RESULTS.md for per-file detail):

linux (CI-verified)

pytest & plugin ecosystem (the APIs pytest-rs reimplements):

suite tag passed failed errors skipped total pass % files all-pass files run files excluded
pytest 9.0.3 1419 708 42 24 2193 64.7% 6 45 63
pytest-asyncio v1.4.0 268 0 0 0 268 100.0% 30 30 0
pytest-mock v3.15.1 85 0 0 5 90 94.4% 1 1 0
pytest-cov v7.1.0 182 24 0 3 209 87.1% 0 1 0
pytest-xdist v3.8.0 89 8 0 0 97 91.8% 0 1 6
pytest-split 0.9.0 59 0 0 0 59 100.0% 1 1 3
pytest-benchmark v5.1.0 91 31 0 1 123 74.0% 4 7 6
pytest-timeout 2.4.0 40 0 0 1 41 97.6% 1 1 0
anyio 4.13.0 3120 0 0 42 3162 98.7% 26 26 0

Real-world projects (their suites run unchanged, as drop-in evidence):

suite tag passed failed errors skipped total pass % files all-pass files run files excluded
click 8.3.1 1314 0 0 21 1335 98.4% 20 20 0
jinja 3.1.6 909 0 0 0 909 100.0% 22 22 0
marshmallow 4.1.1 1119 0 0 0 1119 100.0% 12 12 3
rich v14.2.0 855 0 0 25 880 97.2% 60 62 0

The suites are included as shallow git submodules under conformance/suites/ at the pinned release tags. Initialize them once after cloning:

git submodule update --init --depth 1

Then run the full conformance harness:

cargo build
uv run --no-project python conformance/runner.py --local   # uses submodules
uv run --no-project python conformance/runner.py           # re-clones from upstream (CI mode)
Project License Tag
pytest MIT 9.0.3
pytest-asyncio Apache-2.0 v1.4.0
pytest-mock MIT v3.15.1
pytest-cov MIT v7.1.0
pytest-xdist MIT v3.8.0
pytest-split MIT 0.9.0
pytest-benchmark BSD-2-Clause v5.1.0

pytest-rs reimplements the public APIs of these projects, plus anyio's pytest plugin (MIT). Parts of the bundled Python shims are ports of upstream code; see THIRD-PARTY-NOTICES.md. Credit for the API design and the test suites belongs to their respective authors.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

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

pytest_rs-0.0.3.tar.gz (356.2 kB view details)

Uploaded Source

Built Distributions

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

pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

pytest_rs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

pytest_rs-0.0.3-cp313-cp313-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file pytest_rs-0.0.3.tar.gz.

File metadata

  • Download URL: pytest_rs-0.0.3.tar.gz
  • Upload date:
  • Size: 356.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytest_rs-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9e64873f5f322049cfbc734f2552e708c5e9cccc65f21bf0274ac92aab00975d
MD5 c932061afc698a12792a631f875b93cc
BLAKE2b-256 f78e694c1e86f00f571ac8f472af7657b4b9da0c68ed1cd543a3fb217000e744

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3.tar.gz:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9c162b04dd3ba51985b7d7b770c15257e8fee6ea19a36c2bfcb8eff6504e982
MD5 17090fbfe033d146f34c953664483331
BLAKE2b-256 69abde56e05dd51895c7e9b51b71ec2eade5cfa89298df10835b402d648900c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aeaed87286a9a826df40d5a350c01c4c1f8a7b3a39ddbad0ee6bf9aa7e63fc48
MD5 fddfd0e43cd57511505a2f0b33b633ec
BLAKE2b-256 92289f9b8c9c9b19e5e8b98d27a7c8868f897025f9a166c0e62a63ad27adc0c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3-cp314-cp314-manylinux_2_28_aarch64.whl:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_rs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed140ac1b2e481c5f49d0a32ddf42a9c75656e3f0d9ba5684fd4c155bc4615e0
MD5 617d0f70695d82c04b0c3a0d87417a3c
BLAKE2b-256 8a3840fe6257cf1e43c254863fa5fc4dc52bb04f76b40634630a32bfa0d266e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e707bb1680109b7103c46e1c3fcc4ed82c737e9bceaac4f7c940edacc1e101b
MD5 86339a1e2d76adaa319096367dbb1b7a
BLAKE2b-256 e5ea9f5ec39627b634e6ecafe305d5d4646a5f3eaff48ecdd95bc57af3104bd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a6f847ece944cf51501a3baf4a0e8b6fdf37980f037f1741607786aaa7b3e278
MD5 bee0628a95bf9111641577789cce3e53
BLAKE2b-256 877a0438be4916e48b6dd3b5561a57ea3f51ac7e2fe5e0a171786c8c8c5429db

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_rs-0.0.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d01a628f1f4c2acb98b156bca6c793a17f480ddb72cbb974ccf26b90c2f9ed48
MD5 91d8b579fa32573e8c0e2f6d2a88d0f2
BLAKE2b-256 065af9aeed66ba7f095020bf412dff294435e2e6f9f532148e206b5c5abd40ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on Yasu-umi/pytest-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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