Skip to content

thejchap/tryke

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

190 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tryke-small

Tryke

ruff PyPI license python CI docs

tryke.mp4

Getting started

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 test
tryke 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

Coming from pytest?

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.

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

Languages