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, 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; 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

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 1861 356 4 24 2245 82.9% 8 45 63
pytest-asyncio v1.4.0 268 0 0 0 268 100.0% 30 30 0
pytest-mock v3.15.1 87 0 0 1 88 98.9% 1 1 0
pytest-cov v7.1.0 186 20 0 3 209 89.0% 0 1 0
pytest-xdist v3.8.0 90 8 0 0 98 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
anyio 4.13.0 3120 0 0 42 3162 98.7% 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 total pass % files all-pass files run files excluded
pytest-timeout 2.4.0 40 0 0 1 41 97.6% 1 1 0
pytest-mypy v1.0.1 24 54 0 0 78 30.8% 0 1 0
pytest-ruff v0.5 10 0 0 0 10 100.0% 1 1 0
pytest-subtests v0.14.2 10 22 0 0 32 31.2% 0 1 0
pytest-metadata v2.0.4 5 5 0 0 10 50.0% 0 1 0
pytest-snapshot v0.9.0 100 7 0 0 107 93.5% 0 3 0
pytest-icdiff 0.5 7 5 0 0 12 58.3% 0 1 0
pytest-socket 0.7.0 59 6 0 0 65 90.8% 2 6 0
pytest-order v1.4.0 85 49 0 0 134 63.4% 3 16 0
pytest-repeat v0.9.4 11 5 0 0 16 68.8% 0 1 0
pytest-instafail v0.5.0 48 15 0 0 63 76.2% 0 1 0
pytest-env 1.6.0 67 8 0 0 75 89.3% 2 3 0
pytest-rerunfailures 9.1.1 34 13 0 1 48 70.8% 0 1 0
pytest-randomly 4.1.0 32 5 0 0 37 86.5% 0 1 0
pytest-bdd 8.1.0 37 101 0 1 139 26.6% 6 35 0
pytest-django v4.9.0 146 69 0 1 216 67.6% 2 13 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.4.tar.gz (435.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.4-cp314-cp314-manylinux_2_28_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

pytest_rs-0.0.4-cp314-cp314-manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

pytest_rs-0.0.4-cp314-cp314-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pytest_rs-0.0.4-cp313-cp313-manylinux_2_28_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pytest_rs-0.0.4-cp313-cp313-manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

pytest_rs-0.0.4-cp313-cp313-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pytest_rs-0.0.4.tar.gz
  • Upload date:
  • Size: 435.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.4.tar.gz
Algorithm Hash digest
SHA256 3a11512d86066a421c328e62b02822b894d449d36ecaa35741bfeeadc1ec59eb
MD5 5293a01b896339c04d714754b9743075
BLAKE2b-256 70f72b7d4c5b73be5dc09fd66dbf1caf6b8e0dce623367bff8168e1723c31ce6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_rs-0.0.4-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0868f89cf502a3a14aed4d6fc28fe5628e2fc7e4c14282ff5801350abca4e1fa
MD5 0c0537e8a45a5b0a33140a0a0815e9cb
BLAKE2b-256 d56a25db1e56f509f11931810bc456b8cc535c0f60c5259aace6b69a5090b2b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_rs-0.0.4-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 97a663a6214e0f16a786f2a1c8a8950faf2589d908c22edb3dbadc76dc38587b
MD5 1a202920684701632521e64f50f0dc58
BLAKE2b-256 432cf70ab6bbc01fb3b5880ccb903f82db0a3a65274f8969772fabe1d9aa5587

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_rs-0.0.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aacd101b3b272c78bb4d4dbf255b8dd7cc3899819b61160132a69867a89c8590
MD5 0ec639be3459a400637395b383d6cb07
BLAKE2b-256 44a72f8005b25672210c675d76196fedca76949754620d31eb691dc0091f33dc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_rs-0.0.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c664e24c8ec3b561c3d0d3e9eaa0deb44e7d2721fcd1baa889f2490231c0364
MD5 f82970e247da8b43bbc6a525ae3e3dd5
BLAKE2b-256 17ab4c5f797d7217385d52c5be6922688acf9fcd46453d9d22901600471e9d23

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_rs-0.0.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2cf09af5a8a503acea27454d7cfcbce2be1b3125ce777de895da35c02a1c9305
MD5 f5a83c6a7e62ce84a91abac94256b5df
BLAKE2b-256 3201d314b116706086fba1aa30d13244abf26a00b6a1ff3de8f1a051fa93239a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_rs-0.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 baf80b29aff7b524dc96e468ac2766775aee5b00a31d5b1be6811f4a9c0d34a0
MD5 6b8eb7c2daff7d2bcbeda4dafcfeb3d9
BLAKE2b-256 3c5275e6725c8cbc0a0a9f75365cb17e3a1ec642f7b5f11f4f1cc7748425fe5c

See more details on using hashes here.

Provenance

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