AI-driven test assertion decorator for natural language testing
Project description
shouldpy
"Write your tests the way you always have. Let AI run one final check."
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 areturn. 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
assertchecks 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
- Bring your own API key. shouldpy calls the LLM you configure; it never manages credentials itself.
- 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.
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shouldpy-2.0.0.tar.gz.
File metadata
- Download URL: shouldpy-2.0.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d56d90fef531eac2ebb22c742f600cc49a821dfabd5047d626ab532807138562
|
|
| MD5 |
bf85de33d1adf95dcf189fa5fbf48442
|
|
| BLAKE2b-256 |
90adfb852123d710e93d85f99a264c3f1daea2e354092e854513817df824b0e3
|
Provenance
The following attestation bundles were made for shouldpy-2.0.0.tar.gz:
Publisher:
publish.yml on zhixiangxue/should-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shouldpy-2.0.0.tar.gz -
Subject digest:
d56d90fef531eac2ebb22c742f600cc49a821dfabd5047d626ab532807138562 - Sigstore transparency entry: 1467080664
- Sigstore integration time:
-
Permalink:
zhixiangxue/should-ai@c6b9c2c4f7f09bd6636c21dbff4bba3753caf28e -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/zhixiangxue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6b9c2c4f7f09bd6636c21dbff4bba3753caf28e -
Trigger Event:
release
-
Statement type:
File details
Details for the file shouldpy-2.0.0-py3-none-any.whl.
File metadata
- Download URL: shouldpy-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64936af5bfbce3b9253e2148e308fee4b22f3f0032ab62fe72649f6f69a8c825
|
|
| MD5 |
818c636b5bac640bc76b248fa3ee6bc6
|
|
| BLAKE2b-256 |
ca1bccead0a238621c4e9a4bc6b8f391b09d48e1fc9d5d4e4930c0c95d75d7df
|
Provenance
The following attestation bundles were made for shouldpy-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on zhixiangxue/should-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shouldpy-2.0.0-py3-none-any.whl -
Subject digest:
64936af5bfbce3b9253e2148e308fee4b22f3f0032ab62fe72649f6f69a8c825 - Sigstore transparency entry: 1467080737
- Sigstore integration time:
-
Permalink:
zhixiangxue/should-ai@c6b9c2c4f7f09bd6636c21dbff4bba3753caf28e -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/zhixiangxue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6b9c2c4f7f09bd6636c21dbff4bba3753caf28e -
Trigger Event:
release
-
Statement type: