Skip to main content

Tryke - A 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 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"
            # Pass a label as the second argument to expect() so reports
            # show "returns stored email" instead of the raw expression
            t.expect(users["alice"], "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"], "stores email under user key").to_equal(
                "bob@example.com"
            )

Run your tests — tryke test --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.25

sample.py:
  users
    get
      ✓ returns a stored user [0.00ms]
        ✓ returns stored email
    set
      ✓ stores a new user [0.00ms]
        ✓ stores email under user key

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  10:02:24
   Duration  36.36ms (discover 0.76ms, tests 35.60ms)

  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.

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

Uploaded Python 3Windows x86-64

tryke-0.0.27-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

tryke-0.0.27-py3-none-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: tryke-0.0.27-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.27-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2eb77713f9383ced6dd79ca292c43a9bf505a56ee022a4e0ade0903b869cfd21
MD5 312a0084dc8c3b57e21df9caf46f6489
BLAKE2b-256 a02cbfc0aa1cb5131a05fc41f67fc167e7b283e884ac0846af4c238ef05ae84b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tryke-0.0.27-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.27-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a130320fa9e5bae9b38209e5fa7fd08711d9f36df8f31ede4a533333553ecef
MD5 8159a27adc1f291bb9e042c9f3bffb73
BLAKE2b-256 cc4e87f35d252a59c231ad7e0921e3fa540e758de5b61ee76a948fc07fe789c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tryke-0.0.27-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.27-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 889888f040063bba02c0b645431e4362af4746555ec62393820254d88242c704
MD5 bc8d74666fcbc5eab17600fa052a7edc
BLAKE2b-256 9a6e3468a60bc125ae4deb4bc21f5bd5088b99a4477393be2e378fba14cd6275

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