Skip to content

Python Testing Patterns

Write pytest tests with fixtures, mocks, and TDD practices for Python code

Repository
wshobson/agents
Stars
42,095
Licence
MIT
Files
3 files

What it does

When installed, the agent follows a structured guide for writing Python tests with pytest. It knows how to organize test folders, name tests clearly, use the Arrange-Act-Assert pattern, mock retries and time-dependent behavior, mark slow or integration tests, and measure coverage. It is a reference of conventions and examples rather than a tool that runs anything by itself.

Great for

  • Python developers who want consistent, readable pytest suites
  • Teams setting up a test structure or CI test runs for the first time
  • Developers learning test-driven development or mocking with unittest.mock and freezegun

Skip it if

  • Non-Python projects, since the examples are specific to pytest and Python (use a skill for your language instead)
  • Anyone expecting the agent to run tests automatically without a Python environment, because the skill only supplies guidance and examples

Try asking

  • “Write pytest unit tests for this Python module using the Arrange-Act-Assert pattern”
  • “Set up a tests/ folder with unit and integration subfolders and a conftest.py”
  • “Add tests that mock a flaky API client and verify retry behavior”
  • “Mark slow tests and configure pytest to skip them in quick runs”
Step-by-step guide: how to use Python Testing PatternsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 3 original files, the MIT licence and an attribution note.

    python-testing-patterns.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip python-testing-patterns.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip python-testing-patterns.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Name the module or code you want tested so the agent can match the examples to your real functions
  • Tell the agent your existing test framework and folder layout so it adapts rather than reorganizing your project
  • Review any generated test commands before running them, especially pip installs, since the agent may run them in your environment

What's inside

  • references/advanced-patterns.md
  • references/details.md
  • SKILL.md

Redistributed unmodified from wshobson/agents under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.