Skip to content

Tryke

A Rust-based Python test runner with a Jest-style API.

ruff PyPI license python CI docs

Highlights

Getting started

Run tryke with uvx to get started quickly:

uvx tryke test

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:

uvx tryke test # run once
uvx tryke # watch mode

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.