Skip to main content

tryke — python testing tool

Project description

tryke-small

Tryke

ruff PyPI license python CI docs

Getting started

For more information, see the documentation.

Write a test.

from tryke import Depends, describe, expect, fixture, test


class Users:
    def __init__(self) -> None:
        self._rows: dict[int, str] = {}

    def create(self, name: str) -> int:
        user_id = len(self._rows) + 1
        self._rows[user_id] = name
        return user_id

    def get(self, user_id: int) -> str:
        return self._rows[user_id]


# Fixtures combine setup + teardown in one function. `yield` splits them;
# `per="scope"` caches the value for every test in the lexical scope.
@fixture(per="scope")
def users():
    db = Users()
    yield db
    db._rows.clear()  # Teardown: runs once after the whole describe block.


with describe("users"):

    # Dependencies are explicit and typed — `Depends(users)` resolves to
    # the `Users` return type above, no magic name-matching required.
    @test
    def create_and_get(db: Users = Depends(users)):
        user_id = db.create("alice")
        # Assertions are soft by default: all three run even if one fails,
        # so you get the full diagnostic in a single run.
        expect(user_id).to_equal(1)
        expect(db.get(user_id)).to_equal("alice")
        expect(lambda: db.get(999)).to_raise(KeyError)

    # Parametrize with `@test.cases` — each case is its own test ID,
    # labels are arbitrary strings, kwargs are statically type-checked.
    @test.cases(
        test.case("lowercase", name="alice"),
        test.case("with spaces", name="Alice Liddell"),
        test.case("unicode", name="Алиса"),
    )
    def round_trips_names(name: str, db: Users = Depends(users)):
        expect(db.get(db.create(name))).to_equal(name)

    # Native async — no `pytest-asyncio` plugin needed.
    @test
    async def async_create(db: Users = Depends(users)):
        expect(db.create("bob")).to_be_greater_than(0)

    # Skip / xfail / todo markers ship in the box.
    @test.xfail("reserved-name handling not implemented yet")
    def rejects_reserved_names(db: Users = Depends(users)):
        expect(lambda: db.create("admin")).to_raise(ValueError)

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tryke-0.0.20-py3-none-win_amd64.whl (4.2 MB view details)

Uploaded Python 3Windows x86-64

tryke-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

tryke-0.0.20-py3-none-macosx_11_0_arm64.whl (4.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file tryke-0.0.20-py3-none-win_amd64.whl.

File metadata

  • Download URL: tryke-0.0.20-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tryke-0.0.20-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2896d40b6947ef27b2fafe3a4362d8059bf1e7ccd5c31b9191530adba447b7e2
MD5 4ed62734806deb7211e8c78bf79fb67f
BLAKE2b-256 0eaf70909087af3eb39977a12679e6cf85a4cb01f7c2a5e5882b97b5f9a3bc5f

See more details on using hashes here.

File details

Details for the file tryke-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tryke-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 4.8 MB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tryke-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9661b21fbe2b44910c6bc4368019bdaff45c9011df7f75bdf6a830f64f49aa05
MD5 c1d78420f8206653210d1a65751dfa01
BLAKE2b-256 e0d7bc31f59d40bb8fe584400f9d619351fb576eb18ae289386aa90742a7b54b

See more details on using hashes here.

File details

Details for the file tryke-0.0.20-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tryke-0.0.20-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tryke-0.0.20-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76fba5917067acc4aab1fef230c41751918c23ea5b26284353c10f03f863582d
MD5 dbf9f806b15a7fb4521e0d574754c43c
BLAKE2b-256 21191dcf896e89e1967d72db4e86d54bdf8cbf3c45f5855ea1d39f5657792011

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page