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.19-py3-none-win_amd64.whl (4.2 MB view details)

Uploaded Python 3Windows x86-64

tryke-0.0.19-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.19-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.19-py3-none-win_amd64.whl.

File metadata

  • Download URL: tryke-0.0.19-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.19-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a41d2c3432c5d4f2d201369a6831cb8f5ce54aa102abf23b0898153243ffab12
MD5 f1bab20c02fda60c079364bddfdd9555
BLAKE2b-256 902a7ae0c1ba3aee10ef97b35770f76e3dc4005965f536d1fbcdff30d58c5a1e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tryke-0.0.19-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.19-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7ffa8e0cb876d9267cd565b58097c859f81298a7c7d377d517c023b3d9c415b
MD5 1e49905ff89c5912adf256e5fdc0f1b6
BLAKE2b-256 f6f136695d0d015fe2d87f07c458df6b03f0a0c42b80834a0cf4389858d5d877

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tryke-0.0.19-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.19-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e42b2edb3983944e1e6b040ce001851706821c24b445adea5fde6c4aafb4f35
MD5 39177f1e8705cf27ecab4aae5b202db7
BLAKE2b-256 89473677ec0fd3ff4f3979849471fa4ca8c055f942adb0c64d6613cd31fe0d87

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