Skip to content
Back to skills

Neo Py Test Creator

ASecurity

Automatically generates pytest-compatible unit test templates from Python function signatures and docstrings

  • 7 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added June 7, 2026
testingpythonbashnodetestingci/cdperformancedocumentation

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 12 files and shows the line behind each finding

Scanned June 7, 2026

npx -y skills add modbender/skill-library-mcp --skill neo-py-test-creator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Neo Py Test Creator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Neo Py Test Creator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/modbender-neo-py-test-creator/badge)](https://www.skillsdirectory.com/skills/modbender-neo-py-test-creator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: py-test-creator
description: Automatically generates pytest-compatible unit test templates from Python function signatures and docstrings
---

# py-test-creator — Skill Documentation

## Overview

`py-test-creator` is an OpenClaw skill that automatically generates comprehensive pytest unit test templates from Python code. It parses function signatures, type hints, and docstrings to create actionable test scaffolding that covers edge cases and parameter combinations.

**Key features:**
- Parse Python functions with complex signatures (defaults, type hints, variadic args)
- Generate pytest-compatible test methods with proper assertions
- Handle both standalone functions and class methods
- Convert docstrings into test method documentation
- Create ready-to-use test files with correct imports and structure

## Installation

Dependencies are managed via `package.json`. Install with:

```bash
npm install
```

This will install the required Python packages (pytest, ast-parser utilities) and Node.js dependencies for the skill runner.

## Usage

Trigger the skill with natural language:

- "Create unit tests for this Python function"
- "Generate test templates from these function signatures"
- "Write pytest tests for my Python methods"
- "Create unit test scaffolding from docstrings"

The skill expects a Python file or code snippet as input and produces a corresponding test file.

## Input/Output

**Input:**  
A Python file path or raw code containing one or more functions/methods.

**Output:**  
A test file (e.g., `test_<original>.py`) containing pytest test functions with:
- `import pytest` statements
- Test fixtures for common parameter types
- Edge case coverage (None values, boundaries, invalid types)
- Parametrized tests where appropriate
- Docstrings explaining test purpose

**Example:**

Input (`utils.py`):
```python
def add(a: int, b: int) -> int:
    """Add two integers and return the result."""
    return a + b
```

Output (`test_utils.py`):
```python
import pytest
from utils import add

def test_add_basic_integers():
    """Test add function with basic positive integers."""
    assert add(1, 2) == 3

def test_add_negative_numbers():
    """Test add function with negative integers."""
    assert add(-1, -2) == -3

def test_add_zero():
    """Test add function with zero."""
    assert add(0, 5) == 5
    assert add(5, 0) == 5

def test_add_large_numbers():
    """Test add function with large integers."""
    assert add(1000000, 2000000) == 3000000
```

## Configuration

No configuration required. The skill uses default pytest conventions.

**Optional environment variables:**
- `PYTEST_STRICT`: Set to `true` to enable strict mark handling
- `TEST_COVERAGE`: Set to `true` to include coverage hints in generated tests

## Error Handling

The skill exits with non-zero status on:
- Invalid Python syntax
- Missing input file/code
- Permission errors writing output
- AST parsing failures

Error messages are logged to stderr.

## Limitations

Out of scope:
- Running or validating generated tests
- Integration/end-to-end testing
- Multi-language support (Python only)
- CI/CD integration
- Performance optimization of tests

## Files

The skill package includes:

```
skill/
├── SKILL.md           # This documentation
├── package.json       # NPM package definition
├── README.md          # Quick start guide
└── scripts/
    ├── main.py        # CLI entry point
    ├── parser.py      # Python AST parser
    ├── generator.py   # Test template generator
    └── cli.py         # Command-line interface
```

## Resources

- [pytest Documentation](https://docs.pytest.org/)
- [Python AST Module](https://docs.python.org/3/library/ast.html)
- [OpenClaw Skill System](https://docs.openclaw.ai)

## Support

For issues, feature requests, or contributions, visit:
- Repository: `openclaw/openclaw`
- Discord: https://discord.com/invite/clawd

## License

MIT © OpenClaw Contributors

Files in this skill

  • README.md1010 B
  • SKILL.md4 KB
  • assets/sample-functions.py8.7 KB
  • assets/sample-tests.py23.4 KB
  • package.json1.2 KB
  • references/pytest-conventions.md6.6 KB
  • references/python-ast-guide.md9.6 KB
  • references/testing-patterns.md11.1 KB
  • scripts/cli.py4.2 KB
  • scripts/generator.py12 KB
  • scripts/main.py3.3 KB
  • scripts/parser.py11.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…