python-testing-patterns

Implement pytest testing patterns with fixtures, mocking, parameterization, and property-based testing.

6|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/archibate/archibate-skills --skill python-testing-patterns-archibate
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing-patterns
Source: https://github.com/archibate/archibate-skills/tree/main/old-skills/redundant-skills/python-testing-patterns
Command: npx skills add https://github.com/archibate/archibate-skills --skill python-testing-patterns-archibate

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a comprehensive, practical reference to design, write, and maintain reliable Python tests so developers avoid flaky suites, duplicated patterns, and poor coverage when testing functions, classes, async code, and database interactions.

Core Features & Use Cases

  • Patterns & Examples: Clear, reusable patterns for unit tests, integration tests, async testing, property-based testing, and exception testing.
  • Fixtures & Isolation: Guidance on fixture scopes, autouse fixtures, setup/teardown, and dependency injection for isolated, deterministic tests.
  • Mocking & Parameterization: Strategies for mocking HTTP, database, and async calls; examples of pytest.mark.parametrize and hypothesis for broad input coverage.
  • CI & Coverage: Example CI configuration and coverage reporting recommendations for continuous testing in GitHub Actions or similar pipelines.
  • Use Case: Use these patterns to convert ad-hoc test scripts into organized test suites that run reliably in local development and CI across Python versions.

Quick Start

Create a pytest test suite for a simple module by applying fixtures for setup, parametrize edge cases, mock external services, and run tests with pytest --cov to generate coverage reports.

Frequently Asked Questions about python-testing-patterns

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

FAQPage Schema
How do I write pytest tests for async functions?

To write pytest tests for async functions, apply async testing techniques using pytest-asyncio compatibility patterns. This Skill provides guidance on mocking async calls and structuring tests for asynchronous code to ensure deterministic execution.

What is the best way to parametrize edge cases in pytest?

The best way to parametrize edge cases in pytest is using pytest.mark.parametrize and hypothesis for property-based testing. These patterns allow broad input coverage to validate functions and classes against diverse scenarios efficiently.

How do I mock database and HTTP calls in pytest?

Mock database and HTTP calls in pytest by applying targeted mocking strategies for external services. This Skill provides patterns to isolate dependencies, ensuring integration tests remain reliable and avoid flaky suite executions.

Does this Skill include CI configuration snippets for pytest?

Yes, this Skill includes CI configuration snippets for pytest. It provides example configurations and coverage reporting recommendations to run continuous testing reliably in GitHub Actions or similar CI pipelines across Python versions.

When do I need to use pytest fixtures with autouse?

Use pytest fixtures with autouse when you need automatic setup and teardown for every test without explicit injection. This Skill explains fixture scopes and dependency injection for isolated, deterministic tests.