Skip to main content

shouldpy

"Write your tests the way you always have. Let AI run one final check."

PyPI Python License Downloads

What is this?

A ~200-line decorator that wraps any test function with a natural-language assertion. After the function runs, an LLM inspects all logs, print output, and return values to check whether the condition holds:

  • PASS — passes silently
  • FAIL: reason — raises AssertionError

Does not replace assert. Does not force a return. Does not restructure your test cases. Just one decorator that lets an LLM double-check your work.


Install

pip install shouldpy

Quick start

import should

should.use("openai/gpt-4o-mini", api_key="sk-...")

@should("The log should clearly indicate the order was created successfully")
def test_create_order():
    ...  # your existing test code, unchanged
    logging.info("Order created successfully")
    assert resp.status_code == 200

Run pytest →

  • Your existing assert checks the status code
  • AI additionally checks whether logs/output/return value satisfy the natural-language condition

Both must pass.


Supported models

should.use() accepts any model URI supported by chak:

should.use("openai/gpt-4o-mini",        api_key="...")
should.use("anthropic/claude-3-5-sonnet", api_key="...")
should.use("deepseek/deepseek-chat",    api_key="...")
should.use("ollama/llama3",             base_url="http://localhost:11434")

Async support

@should("Async minor registration must be rejected")
async def test_async_register_minor():
    result = await async_register_user("Alice", 15)
    return result

Works out of the box — async functions get a fully async AI call.


Notes

  1. Bring your own API key. shouldpy calls the LLM you configure; it never manages credentials itself.
  2. Non-deterministic. Best suited for exploratory testing, scripting, local spot-checks, and pre-review sanity passes. Do not use as a primary assertion in high-frequency CI pipelines.
  3. Every call hits the model — slow, costs tokens, and may expose data. For sensitive workloads, use a local model (e.g. Ollama).

Feedback

https://github.com/zhixiangxue/should-ai

Issues, PRs, and stars are welcome.


License

MIT © 2025 zx

Metadata

Release files for shouldpy 2.0.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 shouldpy 2.0.0
File Size Uploaded Provenance
shouldpy-2.0.0.tar.gz 6.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for shouldpy 2.0.0
File Interpreter ABI Platform
shouldpy-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / shouldpy-2.0.0.tar.gz

Download URL shouldpy-2.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d56d90fef531eac2ebb22c742f600cc49a821dfabd5047d626ab532807138562
BLAKE2b-256 checksum
How to use checksums
90adfb852123d710e93d85f99a264c3f1daea2e354092e854513817df824b0e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

Release files / shouldpy-2.0.0-py3-none-any.whl

Download URL shouldpy-2.0.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64936af5bfbce3b9253e2148e308fee4b22f3f0032ab62fe72649f6f69a8c825
BLAKE2b-256 checksum
How to use checksums
ca1bccead0a238621c4e9a4bc6b8f391b09d48e1fc9d5d4e4930c0c95d75d7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

Security for shouldpy 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for shouldpy-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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