Auto-generate pytest tests for Python functions with @autotest decorator
Project description
🧪 autotestify
autotestify is a lightweight Python CLI tool that automatically generates pytest test functions for any function decorated with @autotest.
Save time. Avoid boilerplate. Focus on your logic — we'll write the tests.
🚀 Features
- 🔍 Detects only functions decorated with
@autotest - 🧠 Adds sensible dummy values for parameters
- 🛠 Generates test stubs using
pytest - ⚡ Instantly creates a
test_<filename>.pyfile - 🐍 Pure Python, no dependencies
📦 Installation
Install from PyPI:
pip install autotestify
⚙️ Usage
autotestify your_file.py
This will generate a new file named test_your_file.py in the same directory.
✅ Example
Original file: calculator.py
from autotestify import autotest
def add(a, b):
return a + b
@autotest
def greet(name):
return f"Hello, {name}"
Generated: test_calculator.py
import pytest
from calculator import *
def test_greet():
result = greet("example")
assert result is not None
📌 @autotest Decorator
This is a no-op decorator used for marking which functions should be tested automatically.
from autotestify import autotest
@autotest
def my_function(...):
...
Functions without @autotest will be ignored.
🧩 How It Works
Parses your Python file using the ast module
Identifies functions with @autotest
Analyzes their arguments and generates dummy values
Writes pytest test functions with assert result is not None
🛠 Requirements
Python 3.7+
pytest (to run the tests, not required to generate)
📄 License
MIT © 2025 Sardor Safarov
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 autotestify-0.1.1.tar.gz.
File metadata
- Download URL: autotestify-0.1.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
188c4149482bf32adc2f213f5e0e9f090ccc2de919595fd929e2bb1690115c0a
|
|
| MD5 |
94c119abac81f2fc39c70157427d4fd6
|
|
| BLAKE2b-256 |
88ca5f86ff5ae910e4c6bab7f84cfe3646d6ed63b99ed7ae722db1efc9da3207
|
File details
Details for the file autotestify-0.1.1-py3-none-any.whl.
File metadata
- Download URL: autotestify-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b02174e841800bacbc7391e27da9e7382f926c52d72f335a44755149ff9d85b1
|
|
| MD5 |
0690739b4bc8c5a596ef33d690b7730c
|
|
| BLAKE2b-256 |
075ede619a8227f69112bbf593d33729179782d9791953c351c0e20d9c5341cb
|