home / skills / jeremylongshore / claude-code-plugins-plus-skills / pytest-test-generator

pytest-test-generator skill

/skills/09-test-automation/pytest-test-generator

This skill helps you generate production-ready pytest test configurations and guidance by following industry best practices for test automation.

npx playbooks add skill jeremylongshore/claude-code-plugins-plus-skills --skill pytest-test-generator

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.1 KB
---
name: "pytest-test-generator"
description: |
  Generate pytest test generator operations. Auto-activating skill for Test Automation.
  Triggers on: pytest test generator, pytest test generator
  Part of the Test Automation skill category. Use when writing or running tests. Trigger with phrases like "pytest test generator", "pytest generator", "pytest".
allowed-tools: "Read, Write, Edit, Bash(cmd:*), Grep"
version: 1.0.0
license: MIT
author: "Jeremy Longshore <[email protected]>"
---

# Pytest Test Generator

## Overview

This skill provides automated assistance for pytest test generator tasks within the Test Automation domain.

## When to Use

This skill activates automatically when you:
- Mention "pytest test generator" in your request
- Ask about pytest test generator patterns or best practices
- Need help with test automation skills covering unit testing, integration testing, mocking, and test framework configuration.

## Instructions

1. Provides step-by-step guidance for pytest test generator
2. Follows industry best practices and patterns
3. Generates production-ready code and configurations
4. Validates outputs against common standards

## Examples

**Example: Basic Usage**
Request: "Help me with pytest test generator"
Result: Provides step-by-step guidance and generates appropriate configurations


## Prerequisites

- Relevant development environment configured
- Access to necessary tools and services
- Basic understanding of test automation concepts


## Output

- Generated configurations and code
- Best practice recommendations
- Validation results


## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| Configuration invalid | Missing required fields | Check documentation for required parameters |
| Tool not found | Dependency not installed | Install required tools per prerequisites |
| Permission denied | Insufficient access | Verify credentials and permissions |


## Resources

- Official documentation for related tools
- Best practices guides
- Community examples and tutorials

## Related Skills

Part of the **Test Automation** skill category.
Tags: testing, jest, pytest, mocking, tdd

Overview

This skill automates generation of pytest tests and related configurations for Python projects. It helps produce unit and integration test scaffolding, fixtures, mocks, and CI-friendly test layouts. Use it to accelerate test coverage, enforce patterns, and produce runnable pytest code samples.

How this skill works

The skill inspects the target code, test requirements, and project layout to propose pytest test functions, fixtures, and parametrized cases. It generates code snippets, configuration files (pytest.ini, tox, or GitHub Actions), and suggests mocking or dependency-injection points. Outputs are validated against common pytest conventions and basic linting rules.

When to use it

  • When you need scaffolded pytest tests for existing functions or modules
  • When creating fixtures, parametrized tests, or mocking strategies
  • When configuring CI test runs or pytest.ini / tox setups
  • When you want production-ready test templates following pytest best practices
  • When improving or expanding test coverage quickly

Best practices

  • Generate small, isolated unit tests that assert one behavior per test
  • Use fixtures for shared setup and parametrization for multiple input cases
  • Prefer monkeypatch or unittest.mock for external dependencies to avoid network I/O
  • Include clear arrange-act-assert structure and meaningful test names
  • Add CI configuration that runs tests in a clean environment and fails fast

Example use cases

  • Create pytest test skeletons for a new Python module with typical edge cases
  • Auto-generate fixture-based integration tests for database access using transaction rollbacks
  • Produce parametrized tests for function inputs and expected outputs
  • Generate pytest.ini and GitHub Actions workflow to run tests on push and pull requests
  • Suggest mock patterns and example mocks for external APIs or filesystem interactions

FAQ

Can the skill run tests or only generate code?

It focuses on generating tests and configurations; running tests is done in your environment, though generated CI configs enable automated runs.

Does it handle complex dependencies like async code or DB fixtures?

Yes—outputs include async test patterns, async fixtures, and transaction-aware DB fixture templates when you indicate those needs.