Skip to main content

Add your description here

Project description

Quack Test

A plugin for pytest to evaluate non-deterministic agent components.

A runber duckie taking a test

Installation & Setup

Simply pip install it.

pip install quack-test

To use the LLM judge you will need to add the required config to your .env file.

# OpenAI Provider Configuration
# Set to "OpenAI" or "AzureOpenAI"
OPENAI_PROVIDER=OpenAI

# Unified Configuration
OPENAI_API_KEY=your_api_key_here
OPENAI_MODEL_NAME=gpt-4
OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com/

Run tests

Simply run your tests using pytest (quack_tests are just pytests)

pytest

Writing Tests

You can simply specify @nondeterministic for components, which are not deterministic and should be run multiple times. Implement everything in a test_*.py file in your test or tests folder.

import random
from quack_test import nondeterministic_fixture, nondeterministic_test, judge

@nondeterministic_fixture(n=5)
def sample_text():
    return f"I have {random.randint(1, 10)} apples."

@nondeterministic_test(threshold=0.8)
def test_apples(sample_text):
    return judge(sample_text, criterion="Has more than 1 apple")

@nondeterministic_test(threshold=0.8)
def test_apples_gt(sample_text):
    return judge(sample_text, gt="I have N (0-10) apples")

@nondeterministic_test(threshold=0.8, should_fail=True)
def test_coal(sample_text):
    return judge(sample_text, criterion="Has only coal")

class TestClassBased:
    @nondeterministic_test(n=3, threshold=0.2)
    def test_assert_only(self):
        # Assert-only tests in classes should be treated as successful runs
        return random.random()

Project details


Download files

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

Source Distribution

quack_test-0.2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

quack_test-0.2.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file quack_test-0.2.0.tar.gz.

File metadata

  • Download URL: quack_test-0.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quack_test-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ab5b0adfcf8c40c1d48b672c7df98362521dc37ec8bff41aa797745f3407ac43
MD5 fe75ca3db316b4e61c50d64ef861dacc
BLAKE2b-256 28c635acf1a02dc9c2baf477ea9c3fdfb36160034faf3a73a8c895004f2c5674

See more details on using hashes here.

Provenance

The following attestation bundles were made for quack_test-0.2.0.tar.gz:

Publisher: python-publish.yml on penguinmenac3/quack-test

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quack_test-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: quack_test-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quack_test-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7420e7eaf3278c40b2f0ecd14b88006541100519b9a3806e14b8331935cdf4e
MD5 a43e4faccccb97467010bb57532a5bba
BLAKE2b-256 91f2b13180978b893ae55da08f36931d3c0a45e97e7f1b3d14261bd84cb4ea99

See more details on using hashes here.

Provenance

The following attestation bundles were made for quack_test-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on penguinmenac3/quack-test

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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