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"
t.expect(users["alice"]).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"]).to_equal("bob@example.com")Run your tests — tryke watch for an always-on loop, tryke test --changed
for just what your working tree touched, or plain:
uvx tryke testtryke test v0.0.23
example.py:
users
get
✓ returns a stored user [0.00ms]
✓ expect(users["alice"]).to_equal("alice@example.com")
set
✓ stores a new user [0.00ms]
✓ expect(users["bob"]).to_equal("bob@example.com")
Test Files 1 passed (1)
Tests 2 passed (2)
Start at 08:58:39
Duration 46.01ms (discover 6.08ms, tests 39.93ms)
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.