python-testing-standards

Codify pytest conventions, AAA structure, fixtures, mocking, and coverage standards.

1|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/clostaunau/holiday-card --skill python-testing-standards
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing-standards
Source: https://github.com/clostaunau/holiday-card/tree/main/.claude/skills/python-testing-standards
Command: npx skills add https://github.com/clostaunau/holiday-card --skill python-testing-standards

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill codifies Python testing standards, conventions, and patterns for pytest, fixture usage, mocking, and coverage. It helps teams write reliable tests and maintain quality.

Core Features & Use Cases

  • Test Structure & AAA: Clear test organization and AAA pattern.
  • Fixtures & Mocking: Effective fixture usage and mocking strategies.
  • Coverage & Quality: Guidance on test coverage targets and quality checks.

Quick Start

Start by creating well-structured tests using the AAA pattern, then add fixtures and mocks to isolate behavior.

Frequently Asked Questions about python-testing-standards

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

FAQPage Schema
How do I structure Python tests using the AAA pattern with pytest?

The AAA pattern organizes pytest tests into three phases: Arrange (set up test data and mocks), Act (execute the code being tested), and Assert (verify results). This structure makes tests readable, maintainable, and easier to debug by clearly separating setup, execution, and validation logic.

What's the best way to use pytest fixtures for test isolation?

Pytest fixtures provide reusable, isolated test dependencies by creating fresh instances for each test. Use function-scoped fixtures by default for isolation, session-scoped for expensive setup, and parametrized fixtures to test multiple inputs. This approach prevents test interdependence and ensures deterministic behavior.

How do I mock dependencies effectively in Python unit tests?

Use unittest.mock to replace external dependencies with controlled test doubles. Mock at the point of use, verify mock interactions, and avoid over-mocking internal logic. This isolates the code under test and prevents flaky tests caused by external service calls or side effects.

What code coverage targets should Python test suites aim for?

Aim for 80–90% line coverage using pytest-cov, focusing on critical paths and edge cases rather than arbitrary percentages. Coverage measures test reach, not quality; prioritize testing business logic, error handling, and boundary conditions over trivial code paths.

What are common pytest testing anti-patterns to avoid?

Avoid test interdependence, hardcoded data, missing isolation through fixtures, over-mocking, unclear test names, and tests that verify implementation rather than behavior. Anti-patterns lead to flaky, slow, and hard-to-maintain test suites; follow AAA structure and fixture discipline instead.

Can I use pytest conventions with unittest-style tests?

Pytest runs both pytest-native and unittest.TestCase styles, but pytest conventions—fixtures, parametrization, clear naming—are incompatible with unittest class-based setup/teardown. Migrate to pytest for cleaner syntax, better isolation, and access to advanced features like fixtures and mocking integration.