tryke.mp4
For more information, see the documentation.
Write a test.
from typing import Annotated
import tryke as t
# Fixtures with `per="scope"` are cached for their scope:
# - Module-level for globally defined fixtures
# - Per `describe` block for fixtures defined within a `describe` block
@t.fixture(per="scope")
def database():
db = {}
yield db
db.clear()
with t.describe("users"):
# By default, fixtures run per-test
# Fixtures can be composed by requesting other fixtures
@t.fixture
def users(database: Annotated[dict[str, dict[str, str]], t.Depends(database)]):
database["users"] = {}
return database["users"]
with t.describe("get"):
# Define display labels for tests
# Async tests are supported
@t.test("returns a stored user")
async def test_get(users: Annotated[dict[str, str], t.Depends(users)]):
users["alice"] = "alice@example.com"
# Pass a label as the second argument to expect() so reports
# show "returns stored email" instead of the raw expression
t.expect(users["alice"], "returns stored email").to_equal(
"alice@example.com"
)
with t.describe("set"):
@t.test("stores a new user")
async def test_set(users: Annotated[dict[str, str], t.Depends(users)]):
users["bob"] = "bob@example.com"
t.expect(users["bob"], "stores email under user key").to_equal(
"bob@example.com"
)Run your tests — tryke test --watch for an always-on loop, tryke test --changed
for just what your working tree touched, or plain:
uvx tryke testtryke test v0.0.25
sample.py:
users
get
✓ returns a stored user [0.00ms]
✓ returns stored email
set
✓ stores a new user [0.00ms]
✓ stores email under user key
Test Files 1 passed (1)
Tests 2 passed (2)
Start at 10:02:24
Duration 36.36ms (discover 0.76ms, tests 35.60ms)
PASS
The migration guide has a side-by-side cheat sheet and — faster — a copy-paste LLM prompt that walks an AI coding assistant through a phased, gated pytest → Tryke migration with discovery- and results-parity checks built in.
This repository is licensed under the MIT License.