Skip to content

thejchap/tryke

Repository files navigation

tryke-small

Tryke

ruff PyPI license python CI docs

tryke.mp4

Highlights

Getting started

Run tryke with uvx to get started quickly:

uvx tryke

Or, check out the tryke playground to try it out in your browser.

To learn more about using tryke, see the documentation.

from typing import Annotated

import tryke as t


@t.fixture(per="scope")
def database():
    db = {}
    yield db
    db.clear()


with t.describe("users"):

    @t.fixture
    def users(database: Annotated[dict[str, dict[str, str]], t.Depends(database)]):
        database["users"] = {}

        return database["users"]

    with t.describe("get"):

        @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"], name="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"], 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.

About

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

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors