pytest-patterns

pytest-patterns is a skill for Claude Code, Codex from Everyone-Needs-A-Copilot/claude-copilot. It costs 129 tokens per session (4,225 once invoked), scanned A, original, MIT.

Pytest testing patterns, anti-patterns, and quality rules for Python test files (test.py, test.py, conftest.py). Includes deterministic test-smell detector (pytestsmell.py) for no-assertion tests, empty tests, bare excepts, magic numbers, sleep calls, and print calls. Covers fixtures, parametrize, mock, patch, and…

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns
Any agent
npx skills add Everyone-Needs-A-Copilot/claude-copilot --skill pytest-patterns
Clone the repo
git clone --depth 1 https://github.com/Everyone-Needs-A-Copilot/claude-copilot

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytest-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns.svg)](https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns)
Your own site
<a href="https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns"><img src="https://agentmods.dev/badge/skills/everyone-needs-a-copilot/claude-copilot/pytest-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 129 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,225 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00129 $0.04225
Opus 5 $0.00064 $0.02112
Sonnet 5 $0.00026 $0.00845
Haiku 4.5 $0.00013 $0.00422

Measured today against content hash 85e10117406a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pytest-patterns scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/pytest_smell.py, scripts/test_pytest_smell.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

mock_get = mocker.patch("requests.get")
.claude/skills/testing/pytest-patterns/SKILL.md · 470 lines

How it starts

The opening of the file, as written. The whole thing — 470 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pytest Patterns

Modern pytest testing patterns, anti-patterns, and quality rules for Python.

pytest_smell.py detects structural test smells deterministically. The prose sections below cover judgment-level guidance that the script cannot evaluate. Never re-derive smell detection by eye when the script can do it; always run the script for consistent, auditable findings.

Core Principles

Principle Description
Fixtures over setup Use fixtures for test dependencies
Parametrize Test multiple cases without duplication
Explicit is better Clear test names and assertions
Fast isolation Each test runs independently

Patterns vs Anti-Patterns

Fixtures

# GOOD: Fixtures for test dependencies
@pytest.fixture
def db_session():
    """Provide a clean database session."""
    session = create_session()
    yield session
    session.rollback()
    session.close()

@pytest.fixture
def sample_user(db_session):
    """Create a sample user for tests."""
    user = User(name="John", email="[email protected]")
    db_session.add(user)
    db_session.commit()
    return user

def test_get_user(db_session, sample_user):
    result = get_user_by_id(db_session, sample_user.id)
    assert result.name == "John"

# BAD: Setup in each test
def test_get_user():
    session = create_session()
    user = User(name="John", email="[email protected]")
    session.add(user)
    session.commit()
    # ... test code
    session.rollback()  # Easy to forget cleanup!

Fixture Scopes

# GOOD: Appropriate fixture scopes
@pytest.fixture(scope="session")
def docker_db():
    """Start database container once per test session."""
    container = start_postgres_container()
    yield container
    container.stop()

@pytest.fixture(scope="module")
def api_client():
    """Create API client once per test module."""
    return APIClient(base_url="http://test.local")

@pytest.fixture  # Default: function scope
def clean_data(db_session):
    """Fresh data for each test."""
    yield
    db_session.query(User).delete()

# BAD: Wrong scope causes test pollution
@pytest.fixture(scope="session")  # DANGER!
def user():
    return User(name="John")  # Shared across all tests!

Read the full file on GitHub · 470 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 470 lines · 129 tokens per session scan A 85e10117406a

Subscribe to this mod's changes

pytest-patterns is a skill published in the GitHub repository Everyone-Needs-A-Copilot/claude-copilot (13 stars, last pushed 10d ago), licensed MIT. It adds 129 tokens to every session and 4,225 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.