Metadata-Version: 2.4
Name: shouldpy
Version: 0.1.0
Summary: AI-driven test assertion decorator for natural language testing
Author-email: zx <your-email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/zhixiangxue/should-ai
Project-URL: Repository, https://github.com/zhixiangxue/should-ai
Project-URL: Documentation, https://github.com/zhixiangxue/should-ai#readme
Project-URL: Bug Tracker, https://github.com/zhixiangxue/should-ai/issues
Project-URL: Changelog, https://github.com/zhixiangxue/should-ai/blob/main/CHANGELOG.md
Keywords: testing,ai,assertion,decorator,llm,natural-language
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Provides-Extra: openai
Requires-Dist: langchain-openai>=0.1.0; extra == "openai"
Dynamic: license-file

# shouldpy
> *"已有的测试该怎么写就怎么写，AI 再帮你加一道自然语言安检。"*

[![PyPI](https://img.shields.io/pypi/v/shouldpy.svg)](https://pypi.org/project/shouldpy/)
[![Python](https://img.shields.io/pypi/pyversions/shouldpy.svg)](https://pypi.org/project/shouldpy/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Build Status](https://github.com/zhixiangxue/should-ai/workflows/发布到%20PyPI/badge.svg)](https://github.com/zhixiangxue/should-ai/actions)
[![Downloads](https://img.shields.io/pypi/dm/shouldpy.svg)](https://pypi.org/project/shouldpy/)

## ❓ 这是什么？
仅200多行的小工具：给现有测试函数加一层 **@should("自然语言期望")** 装饰器
AI 会在函数跑完后 **检查** 所有日志、print 输出、返回值，  
判断“期望”是否达成 ——  **PASS** 安静通过；**FAIL: 原因** 抛 `AssertionError`。  

> 不替代 `assert`，不强制 `return`，不改造`testcase`；  
> 仅用一个装饰器让 **LLM 再帮你把把关**。

---

## ⚡️ 安装

```bash
pip install shouldpy

# 其他依赖，按需安装
pip install pytest-asyncio
pip install langchain-openai
```

---

## 👨🏻‍💻 例子

```python
from should import should
from langchain_openai import ChatOpenAI

should.use(ChatOpenAI()) # 指定你的llm

@should("日志里应该明确表示下单成功")
def test_create_order():
    ...  # 原来的测试代码，该怎么写怎么写
    logging.info("订单创建成功")
    assert resp.status_code == 200
```

跑 `pytest` →  
- 原有 `assert` 检查状态码  
- AI 额外检查日志/输出/返回值里有没有“订单创建成功”之类的输出  
两步都过才算通过。

---

## ⚠️ 注意

1. **需要自备** LangChain 兼容 LLM（OpenAI、DeepSeek、Ollama…）。  
2. **不保证确定性** → 适合**教学、脚本、探索式测试、兜底方案**，别拿它当核心断言。  
3. **每次都要调模型** → **慢 + 花钱 + 数据安全** → 别塞进高频 CI；本地跑、CR 前抽查更划算；token敏感或者数据敏感的建议用本地模型

---

## 🤝 反馈
[https://github.com/zhixiangxue/should-ai](https://github.com/zhixiangxue/should-ai)  
issue、PR、star 欢迎！

---

## 📄 License
MIT © 2025 zx
