$npx skillfedfor your agent

python-testing-patterns

Learn to build reliable Python tests using pytest, fixtures, mocking, and test-driven development. This skill covers test organization, naming conventions, retry logic, time control with freezegun, markers, and coverage reporting to help you write maintainable test suites.

Python Testing Patterns helps you write and organize unit tests for Python code using pytest, fixtures, and mocking.

AI-generated summary based on this skill's SKILL.md

38,308 4,097 MITupdated by wshobson

Decision gist · record as of 2026-07-22

Python Testing Patterns helps you write and organize unit tests for Python code using pytest, fixtures, and mocking. Learn to build reliable Python tests using pytest, fixtures, mocking, and test-driven development. This skill covers test organization, naming conventions, retry logic, time control with freezegun, markers, and coverage reporting to help you write maintainable test suites.

manual: git clone https://github.com/wshobson/agents → cp -r agents/plugins/python-development/skills/python-testing-patterns ~/.claude/skills/python-testing-patterns
plugins/python-development/skills/python-testing-patterns/SKILL.md · version 165d0488

Use it when

  • python-testing-patterns covers pytest fixtures as reusable test setup components defined with `@pytest.fixture` that eliminate duplication.
  • python-testing-patterns shows how to organize test suites by grouping related tests in classes or modules.

Verify before relying

Read SKILL.md below before installing (3 files). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

wshobson/agents/python-testing-patterns · repository language: Python

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How to write pytest tests in Python?

python-testing-patterns teaches you to write pytest tests by starting with simple test functions prefixed with `test_`, organizing them into classes, and using assertions. You'll learn naming conventions, test discovery, how to structure test files alongside your code, and best practices for readable, maintainable tests that catch real bugs.

What are pytest fixtures and how do I use mocking?

python-testing-patterns covers pytest fixtures as reusable test setup components defined with `@pytest.fixture` that eliminate duplication. For mocking, you'll learn to replace external dependencies (APIs, databases, files) with stubs using `unittest.mock` or `pytest-mock`, isolate units under test, and verify interactions without side effects.

How do I set up test suites with pytest?

python-testing-patterns shows how to organize test suites by grouping related tests in classes or modules, using conftest.py for shared fixtures, applying pytest markers to categorize tests, and configuring pytest.ini or pyproject.toml for discovery rules. You'll structure tests for unit, integration, and end-to-end layers.

How can I improve code coverage and test quality?

python-testing-patterns helps you measure coverage with pytest-cov, identify untested branches, and set coverage thresholds in CI/CD. You'll learn to write meaningful assertions, avoid flaky tests through proper isolation and cleanup, use parameterization to test multiple scenarios, and apply test-driven development to guide design.

What debugging techniques help when tests fail?

python-testing-patterns teaches debugging failing tests by using pytest's `-vv` flag for detailed output, `--pdb` for interactive debugging, and `--lf` to rerun last failures. You'll learn to isolate test dependencies, control time with freezegun, verify mock calls, and recognize test isolation issues that cause flakiness.

How does python-testing-patterns support test-driven development?

python-testing-patterns emphasizes writing tests before code, using red-green-refactor cycles, and organizing tests to drive API design. You'll learn integration testing for Python APIs, async testing with pytest-asyncio, property-based testing for edge cases, and database testing patterns that support TDD workflows.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

Python Testing Patterns

Comprehensive guide to implementing robust testing strategies in Python using pytest, fixtures, mocking, parameterization, and test-driven development practices.

When to Use This Skill

  • Writing unit tests for Python code
  • Setting up test suites and test infrastructure
  • Implementing test-driven development (TDD)
  • Creating integration tests for APIs and services
  • Mocking external dependencies and services
  • Testing async code and concurrent operations
  • Setting up continuous testing in CI/CD
  • Implementing property-based testing
  • Testing database operations
  • Debugging failing tests

Core Concepts

1. Test Types
  • Unit Tests: Test individual functions/classes in isolation
  • Integration Tests: Test interaction between components
  • Functional Tests: Test complete features end-to-end
  • Performance Tests: Measure speed and resource usage
2. Test Structure (AAA Pattern)

-

(truncated - see the full file via the links below)

File tree — 3 files
plugins/python-development/skills/python-testing-patterns/SKILL.md
plugins/python-development/skills/python-testing-patterns/references/advanced-patterns.md
plugins/python-development/skills/python-testing-patterns/references/details.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Write and organize unit tests for Python code using pytest”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

python-testing
by xu-xiang · xu-xiang/everything-claude-code-zh

Learn to build robust Python tests using pytest with test-driven development principles. This skill covers fixtures for setup and teardown, parametrization for running tests across multiple inputs, mocking to isolate dependencies, and achieving meaningful code coverage targets.

MITdocs in Chineseupdated Mar 2026
★ 1,767repo stars
python-testing
by affaan-m · affaan-m/ECC

Learn pytest essentials and test-driven development patterns for Python projects. This skill covers fixtures, parametrization, mocking, and coverage strategies to build reliable test suites. Follow the red-green-refactor cycle and achieve 80%+ code coverage on your critical paths.

MITupdated Jul 2026
★ 234,207repo stars
python-testing-patterns
by NickCrew · NickCrew/Claude-Cortex

Learn to build reliable test suites in Python using pytest, fixtures, and mocking strategies. This skill covers unit and integration testing, test organization, async testing, and coverage measurement. Discover patterns for parametrized tests, external dependency mocking, and test-driven development workflows.

MITupdated Jun 2026
★ 23repo stars
Pytest Patterns
by hieutrtr · hieutrtr/ai1-skills

Pytest Patterns teaches structured testing for Python backends using pytest, httpx, and factory_boy. Learn to organize tests across unit and integration layers, build reusable fixtures with proper scoping, seed test data with factories, and test async FastAPI endpoints. Covers mocking, parametrization, and conftest hierarchy—but skips frontend and E2E testing.

no license declared → metadata onlyupdated Feb 2026
★ 8repo stars
Pytest Patterns
by manutej · manutej/luxor-claude-marketplace

Pytest Patterns teaches you to write reliable Python tests using pytest's core features—fixtures for setup and teardown, parametrization to run tests with multiple inputs, and mocking to isolate dependencies. Learn test organization, coverage analysis, and CI/CD integration to scale from simple unit tests to complex test suites.

no license declared → metadata onlyupdated Jun 2026
★ 61repo stars
Pytest
by manutej · manutej/luxor-claude-marketplace

Pytest is Python's industry-standard testing framework, built to handle the rigorous demands of customer support systems. This skill covers fixtures, parametrization, mocking, async operations, and database testing with PostgreSQL and SQLAlchemy—everything needed to test ticketing platforms, APIs, and multi-tenant architectures reliably.

no license declared → metadata onlyupdated Jun 2026
★ 61repo stars

More skills Kafka Integration Testing (unlicensed) · django-tdd (MIT) · pytest (MIT) · Pytest Adapter Integration Testing (unlicensed) · testing-perf (MIT)

Tags
unit-testingtest-automationmock-objectscode-coveragetest-infrastructurecontinuous-integrationquality-assurancebehavior-verificationtest-fixtures