write-pytest

Generate pytest unit tests with fixtures and parameterization, plus testcontainers-python integration tests.

1|Updated Apr 21, 2026
One-click install
npx skills add https://github.com/sswapnil2/ai-config-fintech --skill write-pytest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-pytest
Source: https://github.com/sswapnil2/ai-config-fintech/tree/main/skills/write-pytest
Command: npx skills add https://github.com/sswapnil2/ai-config-fintech --skill write-pytest

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Write pytest tests for Python modules with fixtures and parameterization, and ensure integration tests with testcontainers-python. This approach enforces reliable, maintainable tests that scale with codebases.

Core Features & Use Cases

  • Unit testing: cover public functions/classes with fixtures and parameterization.
  • Integration testing: validate behavior with real dependencies via testcontainers.
  • Quality compliance: enforces org rules (no DB mocking, no time.sleep, async correctness).

Quick Start

Write unit tests for a module's public API using fixtures and parameterization, then add integration tests with testcontainers.

Frequently Asked Questions about write-pytest

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

FAQPage Schema
How do I write pytest tests with fixtures and parameterization for a Python module?

To write pytest tests with fixtures and parameterization, you generate unit tests that cover a module's public API using reusable setup components and data-driven inputs. This ensures reliable behavior validation across diverse scenarios without repeating setup code.

What is the best way to run integration tests in Python without mocking the database?

The best way to run integration tests without mocking the database is using testcontainers-python. This approach spins up real dependencies in temporary Docker containers, validating actual data access layer behavior and ensuring ABI stability without brittle mocks.

How do I test asynchronous Python code correctly in pytest?

To test asynchronous Python code correctly in pytest, you apply async correctness patterns that validate coroutine behavior without blocking. This ensures your test suite accurately handles concurrent execution paths and avoids false positives in async functions.

Why should I avoid time.sleep when writing pytest tests?

You should avoid time.sleep in pytest tests because it creates slow, brittle feedback loops by arbitrarily pausing execution. Enforcing a no time.sleep requirement ensures fast feedback and reliable test timing by properly synchronizing test assertions with actual state changes.

Can I use testcontainers-python to validate services and data access layers?

Yes, you can use testcontainers-python to validate services and data access layers. It provisions real, ephemeral dependencies for your integration tests, ensuring your public APIs interact correctly with actual database instances rather than mocked interfaces.

How do I structure pytest unit tests to scale with a growing Python codebase?

To structure pytest unit tests for a growing Python codebase, you apply clear test naming conventions, organize tests by module, and enforce coverage expectations. Using fixtures and parameterization keeps test logic maintainable as the public API expands.