Skip to main content

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 leaves the pytest command itself untouched, but it does install an importable pytest package, so import pytest (fixtures, pytest.raises, pytest.mark, pytest.approx, ...) works standalone too — e.g. from a subprocess that never runs through the pytest-rs binary.

Don't install this alongside the real pytest package in the same environment: both distributions claim the same pytest import path, and pip/uv have no awareness that they conflict — installation order decides which files end up in site-packages/pytest/, and neither installer cleanly removes the other's.

When switching a project over, pytest itself, pluggy, and iniconfig are the only packages pytest-rs supersedes — safe to drop. Any other pytest plugin the project uses (pytest-django, pytest-aiohttp, ...) is a real, separately-installed package unless it's one of the plugins listed under Bundled plugins below, and must stay installed for its fixtures/hooks to keep working.

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, custom collectors (pytest_collect_fileFile/Item), 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). Verified status:

evidence plugins
own upstream test suite runs under pytest-rs and gates CI (per-suite pass-rate in the Third-party plugins conformance table below) pytest-timeout, pytest-randomly, pytest-env, pytest-socket, pytest-snapshot, pytest-ruff, pytest-rerunfailures, pytest-order, pytest-repeat, pytest-instafail, pytest-icdiff, pytest-metadata, pytest-subtests, pytest-mypy, pytest-bdd, pytest-django, pytest-aiohttp; anyio's own plugin module also loads this way
functional smoke demo gates CI (conformance/plugin_smoke.py) Faker, time-machine, requests-mock, inline-snapshot (snapshot assertions + --inline-snapshot flag), pytest-run-parallel (--parallel-threads really runs each test on N threads)
reporter replacement — 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)
not reimplemented yet pytest-html (needs the report data model exposed); syrupy (serializer/extension framework)

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

Startup, collection, fixture orchestration, coverage measurement, and parallel workers are native Rust code. The main wins:

  • --cov runs — coverage is collected via sys.monitoring (Python 3.12+ low-overhead instrumentation) instead of coverage.py's tracing hooks. Typically 2–3x faster, and the gap widens with suite size.
  • -n parallel runs — workers fork off the already-warm parent interpreter by default (unix only), skipping per-worker interpreter/plugin/conftest import cost. Each forked worker still fires its own pytest_configure and collects/applies pytest_collection_modifyitems independently, so behavior matches a freshly spawned worker. Set PYTEST_RS_DIST_SPAWN=1 to opt back into spawning a fresh subprocess per worker (upstream xdist's model) instead.
  • Large collections — fixture resolution and parametrize expansion run in Rust; suites with thousands of tests see faster collection.

Benchmarks on open-source projects (macOS arm64, median of 3 warm runs), reproducible with bench/suites.sh — clones each suite at a pinned tag, installs pytest-rs into its venv, and times both runners.

suite (tests) mode pytest pytest-rs speedup
marshmallow (1119) (plain) 0.44 s 0.32 s 1.4x
marshmallow (1119) --cov 0.86 s 0.42 s 2.0x
marshmallow (1119) -n 3 --cov 0.97 s 0.45 s 2.2x
click (1336) (plain) 1.25 s 1.18 s 1.1x
click (1336) --cov 2.08 s 1.32 s 1.6x
click (1336) -n 3 --cov 1.65 s 1.19 s 1.4x
networkx (6890) (plain) 30.77 s 28.96 s 1.1x
networkx (6890) --cov 128.01 s 42.38 s 3.0x
networkx (6890) -n 3 --cov 48.79 s 22.12 s 2.2x

Small-to-medium suites see a 1.3–1.4x speedup even without coverage, thanks to lower startup overhead. On large suites where test bodies dominate, the plain-mode gap narrows; the bigger wins come from --cov and -n parallelism. Try it on your own suite:

hyperfine -w 1 'pytest -q' 'pytest-rs -q'
hyperfine -w 1 'pytest --cov=mypkg' 'pytest-rs --cov=mypkg'

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 + deselected + known_failed; deselected = tests that never run, excluded via --deselect in conformance/suites.toml because running them would be flaky or environmentally invalid; known_failed = tests that run normally but fail for a known, permanent, accepted reason (matched by exact nodeid against the run's own output, so a test that starts passing again is simply counted as passed instead of masking a real fix); both count against the total but not toward conformance; files excluded = whole files that also fail under vanilla pytest, out of scope; updated automatically by conformance/runner.py — 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 deselected known_failed total conformant % files all-pass files run files excluded
pytest 9.0.3 2783 1 0 53 0 12 2849 99.5% 53 54 61
pytest-asyncio v1.4.0 268 0 0 0 0 0 268 100.0% 30 30 0
pytest-mock v3.15.1 87 0 0 1 0 2 90 97.8% 1 1 0
pytest-cov v7.1.0 205 0 0 3 0 1 209 99.5% 1 1 0
pytest-xdist v3.8.0 96 0 0 2 0 0 98 100.0% 1 1 6
pytest-split 0.9.0 59 0 0 0 0 0 59 100.0% 1 1 3
pytest-benchmark v5.1.0 122 0 0 1 0 0 123 100.0% 6 7 6
anyio 4.13.0 3120 0 0 42 0 0 3162 100.0% 26 26 0

Third-party plugins (not reimplemented — their own upstream test suites run under pytest-rs, loaded via the pytest11 entry-point shim):

suite tag passed failed errors skipped deselected known_failed total conformant % files all-pass files run files excluded
pytest-aiohttp v1.1.1 7 0 0 0 0 0 7 100.0% 2 2 0
pytest-timeout 2.4.0 42 0 0 1 0 0 43 100.0% 1 1 0
pytest-mypy v1.0.1 76 0 0 2 0 0 78 100.0% 1 1 0
pytest-ruff v0.5 10 0 0 0 0 0 10 100.0% 1 1 0
pytest-subtests v0.14.2 32 0 0 0 0 0 32 100.0% 1 1 0
pytest-metadata v2.0.4 10 0 0 0 0 0 10 100.0% 1 1 0
pytest-snapshot v0.9.0 106 0 0 0 0 1 107 99.1% 3 3 0
pytest-icdiff 0.5 10 0 0 0 0 2 12 83.3% 1 1 0
pytest-socket 0.7.0 63 0 0 0 0 2 65 96.9% 6 6 0
pytest-order v1.4.0 134 0 0 0 0 0 134 100.0% 16 16 0
pytest-repeat v0.9.4 16 0 0 0 0 0 16 100.0% 1 1 0
pytest-instafail v0.5.0 63 0 0 0 0 0 63 100.0% 1 1 0
pytest-env 1.6.0 72 0 0 0 0 3 75 96.0% 3 3 0
pytest-rerunfailures 9.1.1 47 0 0 1 0 0 48 100.0% 1 1 0
pytest-randomly 4.1.0 37 0 0 0 0 0 37 100.0% 1 1 0
pytest-bdd 8.1.0 138 0 0 1 0 0 139 100.0% 35 35 0
pytest-django v4.9.0 215 0 0 1 0 0 216 100.0% 12 13 0

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

suite tag passed failed errors skipped deselected known_failed total conformant % files all-pass files run files excluded
click 8.3.1 1314 0 0 21 0 0 1335 100.0% 20 20 0
jinja 3.1.6 909 0 0 0 0 0 909 100.0% 22 22 0
marshmallow 4.1.1 1119 0 0 0 0 0 1119 100.0% 12 12 3
rich v14.2.0 855 0 0 25 0 0 880 100.0% 60 62 0
sqlglot v30.11.0 1120 0 0 0 0 0 1120 100.0% 52 54 0
httpx 0.28.1 1410 0 0 1 0 7 1418 99.5% 31 31 0
httpx2 v2.4.0 1426 0 0 1 0 0 1427 100.0% 31 31 0
starlette 0.46.2 907 0 0 0 0 0 907 100.0% 28 28 0
attrs 25.3.0 1341 0 0 5 0 0 1346 100.0% 22 24 0
more-itertools v10.7.0 670 0 0 1 0 0 671 100.0% 2 2 0
werkzeug 3.1.3 922 0 0 1 25 0 948 97.4% 24 25 0
fastapi 0.115.12 2333 0 0 130 0 1 2464 100.0% 304 310 0
packaging 25.0 26948 0 0 0 0 0 26948 100.0% 12 12 0
pandas v3.0.3 160780 0 0 26985 0 8 187773 100.0% 880 961 3
networkx 3.6.1 6815 0 0 79 0 0 6894 100.0% 259 266 0
pydantic v2.11.7 5338 0 0 921 0 14 6273 99.8% 79 82 0
scikit-learn-1 1.9.0 8432 0 0 6624 0 0 15056 100.0% 79 87 0
scikit-learn-2 1.9.0 5046 0 0 1892 0 0 6938 100.0% 52 58 0
scikit-learn-3 1.9.0 9251 0 0 2530 0 3 11784 100.0% 107 114 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.

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.10.tar.gz (745.0 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.10-cp314-cp314-manylinux_2_28_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

pytest_rs-0.0.10-cp314-cp314-manylinux_2_28_aarch64.whl (4.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

pytest_rs-0.0.10-cp314-cp314-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pytest_rs-0.0.10-cp313-cp313-manylinux_2_28_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pytest_rs-0.0.10-cp313-cp313-manylinux_2_28_aarch64.whl (4.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

pytest_rs-0.0.10-cp313-cp313-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pytest_rs-0.0.10.tar.gz
Algorithm Hash digest
SHA256 f62de3b200278e3c4ac15ad500aaf8e2ed20dcef79cd060f9055eeed27a7bf72
MD5 0ea14d4a08421371a96bfcf5e6e4143e
BLAKE2b-256 86cc48d3faef72fbf5356b7e871b335a641ff0041d446cc939c9e89117b7763e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10.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.10-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.10-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 393d8de4e9e4d75292e07435928e7dc1bf839e6c6fbcb382e848b10f171b6ef7
MD5 0356757cb96c9d2b9cd0d08cfbd2c6eb
BLAKE2b-256 cc1758bae44332a3af19df8a62a1f1dadf2ac3ed3ad349d6f6f16c9114ba2e6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10-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.10-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.10-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 42cc3ed3ede7206c0d4df303837469c703c3206c442ee3467989e00603e6a59d
MD5 6e031c6a7dbbbb5bd8e91075e40a5057
BLAKE2b-256 174b87609d4df873a8f4941638e3f7ad14d8774d054d331f07d9bac645d5c0cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10-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.10-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.10-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00ac5cc6431de6066fc7f78b849a1451829ce4ae44aa63e0cd9fcb6b5073380f
MD5 614421c3cfed132500f79c765783d888
BLAKE2b-256 796ca34cce3ead688a014a71c41407224f47f0cd57ba07729adf44c2005dbe86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10-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.10-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.10-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b46722be38b3e4954661edc8185482bbcd6adfdee4149e8df99626a414c15b0a
MD5 a12a7b41945ef89188b0680ad871e5ac
BLAKE2b-256 aeec7516ff806c271275a6c2e484a07184170c9bf787004b6e104b4935badbc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10-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.10-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.10-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b449bdda8da6ee25846c1fb1499a86ee7dad9fb6fa4627c1a3611d34558b3bc0
MD5 9406b78575f118541cca37487483f2b8
BLAKE2b-256 173ab934b6d47143644a9b3653afe75dc6a4f9fc80b3c4a0f34ee6ba1e5b2e29

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10-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.10-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytest_rs-0.0.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6298403ced7aafb02f2c37a81e02ede36633e3a9b156b64f6ca579d2ea83f46
MD5 52ec7187f917a4048a796c2f7ecbd0dd
BLAKE2b-256 3e35dfa2370c61f11443774bceed8beb2f944f2c50ce91878a27036fa5de9d28

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_rs-0.0.10-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.

Release history Release notifications | RSS feed

0.0.12

7 files

0.0.11

7 files

This release

0.0.10 This release

7 files

0.0.9

7 files

0.0.8

7 files

0.0.7

7 files

0.0.6

7 files

0.0.5

7 files

0.0.4

7 files

0.0.3

7 files

0.0.2

7 files

0.0.1

7 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page