Tryke¶
A Rust-based Python test runner with a Jest-style API.
Highlights¶
- Fast Rust-powered test discovery
- Concurrent tests by default
- Pretty, per-assertion diagnostics
- Soft assertions (like pytest-check)
- Native
asyncsupport — no plugin - Watch mode
- Changed mode (like pytest-picked)
- Client/server mode for fast editor integrations
- Fixtures with setup / teardown and typed
Depends()injection - Parametrized tests via
@test.cases - Grouping with
describe()blocks skip,skip_if,xfail, andtodomarkers- In-source testing
- Support for doctests
- Filtering and marks
- Reporters — text, dot, json, junit, llm, nextest-style, and pytest-sugar-style
Getting started¶
Run tryke with uvx to get started quickly:
Or, check out the tryke playground to try it out in your browser.
from typing import Annotated
from tryke import Depends, describe, expect, fixture, test
@fixture(per="scope")
def database():
db = {}
yield db
db.clear()
with describe("users"):
@fixture
def users(database: Annotated[dict[str, dict[str, str]], Depends(database)]):
database["users"] = {}
return database["users"]
with describe("get"):
@test("returns a stored user")
async def test_get(users: Annotated[dict[str, str], Depends(users)]):
users["alice"] = "alice@example.com"
expect(users["alice"], name="returns stored email").to_equal(
"alice@example.com"
)
with describe("set"):
@test("stores a new user")
async def test_set(users: Annotated[dict[str, str], Depends(users)]):
users["bob"] = "bob@example.com"
expect(users["bob"], name="stores email under user key").to_equal(
"bob@example.com"
)
Run the tests:
Coming from pytest?¶
The migration guide has a side-by-side cheat sheet and a copy-paste LLM prompt.
License¶
This repository is licensed under the MIT License.
Installation¶
See the installation documentation.