pytest-adversarial
LLM-powered adversarial test generation for Python using Quality-Diversity algorithms.
Installation
pip install pytest-adversarial
Quick Example
Test a JSON parser for edge cases:
# target.py
import json
def parse_json(text: str) -> dict:
"""Parse JSON string."""
return json.loads(text)
Run adversarial testing:
pytest-adversarial examples/json_parser/target.py --rounds 10
The tool will automatically:
- Generate adversarial test inputs using LLMs
- Find edge cases that crash your code
- Evolve attacks using Quality-Diversity search
- Report robustness metrics and discovered vulnerabilities
Sample output:
Round 5/10 | Robustness: 73.2% | Attacks: 42 | Types: 8
Found: malformed_unicode, extreme_nesting, special_chars...
Documentation
For detailed usage, examples, and advanced features, visit: github.com/nulone/pytest-adversarial
Requirements
- Python 3.10+
- OpenAI API key (set
OPENROUTER_API_KEYenvironment variable)
License
MIT License - see GitHub repository for details.
Metadata
Release files for pytest-adversarial 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_adversarial-0.1.0.tar.gz | 38.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_adversarial-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 76.1 kB
Release files / pytest_adversarial-0.1.0.tar.gz
| Download URL | pytest_adversarial-0.1.0.tar.gz |
|---|---|
| Size | 38.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bd9c8d78e5df84da87fa5521c7c5dd92ff3b81e271ae3372a9bf9cd1cdb40f3
|
|
BLAKE2b-256 checksum How to use checksums |
804b0ce3183589a9ee3dc89c17d65704c12360b9ee6788fdbaa51017ba6220e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / pytest_adversarial-0.1.0-py3-none-any.whl
| Download URL | pytest_adversarial-0.1.0-py3-none-any.whl |
|---|---|
| Size | 37.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e065064035171b55ba95ae6cebc6589d4465bc0e2f46ca26e61f679e446f587
|
|
BLAKE2b-256 checksum How to use checksums |
a8ac83a7d64f1d4f9fcbc13f13adcfe57e5e4fb194700b4cc8c32befa71aff6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|