python-testing

Enforce robust pytest patterns for fixtures, mocking, and async tests.

Updated Dec 14, 2025
One-click install
npx skills add https://github.com/pproenca/dot-claude --skill python-testing-pproenca
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/pproenca/dot-claude/tree/main/domain_plugins/dev-python/skills/python-testing
Command: npx skills add https://github.com/pproenca/dot-claude --skill python-testing-pproenca

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides patterns for robust Python testing with pytest, including fixtures, parameterization, mocking, and async testing.

Core Features & Use Cases

  • Fixtures and parametrization: Build reusable fixtures and test matrices.
  • Mocking: Simulate dependencies with mocks and patches.
  • Async testing: Write tests with async support to validate asynchronous code.

Quick Start

Write a basic pytest test file and run pytest to verify behavior.

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I write reliable pytest tests with proper fixtures and mocking?

Pytest testing relies on fixtures for setup and teardown, mocking to isolate code under test, and parametrization to run the same test logic across multiple inputs. Fixtures provide reusable test data, mocks replace external dependencies, and parametrization eliminates duplicate test cases while ensuring comprehensive coverage.

What's the difference between mocking and actually testing my code?

Mocking simulates dependencies so you test only your code's logic, not the dependency's behavior. Testing without mocks validates real interactions but couples your tests to external systems. Pytest patterns enforce mocking external APIs and databases while testing your actual implementation logic.

How do I test async code in pytest?

Pytest async testing uses fixtures and plugins to run asynchronous test functions and validate async behavior. You write async test functions, use async fixtures for setup, and pytest executes them in an event loop, letting you test async functions, coroutines, and concurrent operations.

Can I reuse test fixtures across multiple test files?

Yes, pytest fixtures scale across test files through conftest.py files placed in your project root or test directories. Fixtures defined in conftest.py are automatically discovered and available to all tests in that directory and subdirectories, enabling fixture reuse without duplication.

Why should I parametrize tests instead of writing separate test cases?

Parametrization reduces test code duplication by running one test function across multiple input-output pairs, making tests easier to maintain and extend. Pytest generates a separate test case for each parameter set, providing clear failure reports and comprehensive coverage with minimal boilerplate.

What testing patterns prevent common pytest mistakes?

Robust pytest patterns enforce proper fixture scope management to avoid state leakage, use mocking to avoid testing external dependencies, and apply parametrization to eliminate copy-pasted tests. These patterns prevent flaky tests, false positives from mocks, and maintenance overhead.