Skip to main content

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>.py file
  • 🐍 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autotestify-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autotestify-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

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

Hashes for autotestify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 188c4149482bf32adc2f213f5e0e9f090ccc2de919595fd929e2bb1690115c0a
MD5 94c119abac81f2fc39c70157427d4fd6
BLAKE2b-256 88ca5f86ff5ae910e4c6bab7f84cfe3646d6ed63b99ed7ae722db1efc9da3207

See more details on using hashes here.

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

Hashes for autotestify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b02174e841800bacbc7391e27da9e7382f926c52d72f335a44755149ff9d85b1
MD5 0690739b4bc8c5a596ef33d690b7730c
BLAKE2b-256 075ede619a8227f69112bbf593d33729179782d9791953c351c0e20d9c5341cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page