python-regression-test-generator

Generate pytest snapshot regression tests capturing current Python behavior.

1|2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill python-regression-test-generator-santosomar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-regression-test-generator
Source: https://github.com/santosomar/general-secure-coding-agent-skills/tree/main/skills/testing/python-regression-test-generator
Command: npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill python-regression-test-generator-santosomar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps ensure that existing Python code behaves as expected, especially before refactoring or during migrations, by automatically generating regression tests that capture current behavior.

Core Features & Use Cases

  • Snapshot Testing: Generates pytest tests that use snapshot assertions to record and verify current output.
  • Pickle Round-trip: Supports capturing complex custom objects via pickling.
  • Explicit Assertions: Allows for readable, field-by-field assertions for critical paths.
  • Input Generation: Can record real-world inputs from production traffic to create comprehensive test cases.
  • Non-determinism Handling: Provides strategies for managing common sources of non-determinism like datetime.now(), uuid.uuid4(), and random.
  • Use Case: Before refactoring a critical pricing module in a Python application, use this skill to generate regression tests that lock in the current pricing logic, ensuring that any changes don't break existing functionality.

Quick Start

Use the python-regression-test-generator skill to generate pytest snapshot tests for the engine.price function.

Frequently Asked Questions about python-regression-test-generator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate pytest regression tests to capture current Python behavior before refactoring?

Pytest regression tests capture current Python behavior using snapshot assertions, locking in existing logic before refactoring or migrations. The skill generates these tests automatically to ensure code changes do not break existing functionality.

What is the best way to handle non-determinism when snapshot testing Python functions?

Handling non-determinism in Python snapshot testing requires strategies for managing common sources like datetime.now(), uuid.uuid4(), and random. The skill provides built-in approaches to address these non-deterministic outputs during test generation.

How do I create regression tests for complex Python objects using pickle?

Pickle round-trips capture complex custom Python objects by serializing and deserializing them for regression tests. The skill supports this approach alongside snapshot libraries, explicit field assertions, and golden files.

Can I generate pytest test cases from real production traffic in Python?

Generating pytest test cases from production traffic is possible by tracing real-world inputs. The skill facilitates input generation by recording actual production traffic to create comprehensive regression test cases.

When do I need explicit field assertions instead of snapshot testing for Python regression tests?

Explicit field assertions are needed for critical paths where readable, field-by-field verification is preferred over snapshot testing. The skill allows generating these explicit assertions to provide clearer test intent for important logic.

Does this Python regression test generator work without external snapshot testing libraries?

The Python regression test generator supports multiple capture approaches including snapshot libraries, pickle round-trips, explicit field assertions, and golden files, offering flexibility beyond a single snapshot library dependency.