Skip to main content

pytest-pyeval

A pytest plugin integrating pydantic-evals

Run evals via pytest with the power of fixtures and using a familiar Arrange, Act, Evaluate pattern.

Example

from pyeval import dataset, execute, Case, EqualsExpected, Contains


def uppercase_text(text: str) -> str:
    return text.upper()


@dataset(
    Case(
        name="uppercase_basic",
        inputs="hello world",
        expected_output="HELLO WORLD",
    ),
    Case(
        name="uppercase_with_numbers",
        inputs="hello 123",
        expected_output="HELLO 123",
    ),
)
def eval_uppercase(case: Case):
    result = execute(uppercase_text, case)

    result.evaluate(EqualsExpected())
    result.evaluate(Contains(value="HELLO", case_sensitive=True))
$ uv run pyeval

============================== test session starts ==============================
platform darwin -- Python 3.13.1, pytest-9.0.2, pluggy-1.6.0
plugins: anyio-4.12.1, pyeval-0.1.0
collected 2 items

tests/evals/eval_example.py ●●                                                                         [100%]

============================= 2 evaluated in 0.02s ==============================

Installation

uv add --dev pytest-pyeval

Running evals

pytest-pyeval keeps evals separate from your regular test suite. Evals are excluded from pytest by default, since they are typically slower, hit live APIs, and run on a different cadence to unit tests.

Command What runs
pytest Regular tests only (test_*.py)
pytest --evals Eval tests only (eval_*.py)
pyeval Shorthand for pytest --evals
pyeval                     # discover and run all evals in the project
pyeval evals/              # run evals under a specific path
pyeval evals/eval_foo.py   # run a single eval file

Release files for pytest-pyeval 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-pyeval 0.4.0
File Size Uploaded
pytest_pyeval-0.4.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-pyeval 0.4.0
File Interpreter ABI Platform
pytest_pyeval-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size:16.1 kB

Release files / pytest_pyeval-0.4.0.tar.gz

Download URL pytest_pyeval-0.4.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1dbed65d77e41a627723b9cf1d01518b436b41d48ea517fde0cf83ad0243b597
BLAKE2b-256 checksum
How to use checksums
ec8c4aee96c46dedbbffe3e4fc433fe8ce0f28d4536db93844f8daf0a92cce8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pytest_pyeval-0.4.0-py3-none-any.whl

Download URL pytest_pyeval-0.4.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
592b415ac95544fdab28d46f4be63c472931af212e2c5b40e26417cd7e77ba4b
BLAKE2b-256 checksum
How to use checksums
37c6a88727919988d8b9ad2f9d5ad3438832342e9bb3ad822d43d6aaa9bc3359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page