python-testing

python-testing is a skill for Claude Code, Kiro from affaan-m/ECC. It costs 35 tokens per session (2,527 once invoked), scanned A, original, MIT.

A guide to testing Python code with pytest, a tool for checking that programs behave as expected. It covers reusable test setup, test variations, mocked dependencies, asynchronous code, coverage, and test organization.

In plain words
What is it for?
Use it when writing or improving tests for Python functions, classes, database code, asynchronous code, or existing untested projects.
Why use it?
It gives structure to Python tests and helps catch regressions without repeating setup or relying on real external services.

Skill for Claude CodeKiro

Written for Claude Code and Kiro: shipped in a Claude Code plugin, but also installed under .kiro/.

Part of the ecc plugin — 70 skills, 56 commands, 68 agents, 1 MCP server shipped together

About the project

ECC is a toolkit that organizes and improves how coding agents work through skills, memory, security checks, research practices, and related extensions. It is for developers using agents such as Claude Code, Codex, OpenCode, and Cursor.

affaan-m/ECC · 250,130 stars · on GitHub · ecc.tools

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/affaan-m/ecc/python-testing
Any agent
npx skills add affaan-m/ECC --skill python-testing
Clone the repo
git clone --depth 1 https://github.com/affaan-m/ECC

Made for: Claude Code, Kiro.

Or install ecc, the plugin that ships this one along with the rest of its 70 skills, 56 commands, 68 agents, 1 MCP server.

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 python-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/affaan-m/ecc/python-testing.svg)](https://agentmods.dev/skills/affaan-m/ecc/python-testing)
Your own site
<a href="https://agentmods.dev/skills/affaan-m/ecc/python-testing"><img src="https://agentmods.dev/badge/skills/affaan-m/ecc/python-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,527 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified. ✓ AI security review Fable 5.1 · 6 Sept 2026
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.1 $0.00035 $0.02527
Opus 5 $0.00017 $0.01264
Sonnet 5 $0.00007 $0.00505
Haiku 4.5 $0.00003 $0.00253

Measured 2d ago against content hash 9961c5536f09, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

python-testing scanned grade A with 0 findings 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 2d ago.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

4 near-identical copies found in the catalogue:

.kiro/skills/python-testing/SKILL.md · 498 lines

How it starts

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

Python Testing

This skill provides comprehensive Python testing patterns using pytest as the primary testing framework.

Testing Framework

Use pytest as the testing framework for its powerful features and clean syntax.

Basic Test Structure

def test_user_creation():
    """Test that a user can be created with valid data"""
    user = User(name="Alice", email="[email protected]")

    assert user.name == "Alice"
    assert user.email == "[email protected]"
    assert user.is_active is True

Test Discovery

pytest automatically discovers tests following these conventions:

  • Files: test_*.py or *_test.py
  • Functions: test_*
  • Classes: Test* (without __init__)
  • Methods: test_*

Fixtures

Fixtures provide reusable test setup and teardown:

import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

@pytest.fixture
def db_session():
    """Provide a database session for tests"""
    engine = create_engine("sqlite:///:memory:")
    Session = sessionmaker(bind=engine)
    session = Session()

    # Setup
    Base.metadata.create_all(engine)

    yield session

    # Teardown
    session.close()

def test_user_repository(db_session):
    """Test using the db_session fixture"""
    repo = UserRepository(db_session)
    user = repo.create(name="Alice", email="[email protected]")

    assert user.id is not None

Fixture Scopes

@pytest.fixture(scope="function")  # Default: per test
def user():
    return User(name="Alice")

@pytest.fixture(scope="class")  # Per test class
def database():
    db = Database()
    db.connect()
    yield db
    db.disconnect()

@pytest.fixture(scope="module")  # Per module
def app():
    return create_app()

@pytest.fixture(scope="session")  # Once per test session
def config():
    return load_config()

Fixture Dependencies

@pytest.fixture
def database():
    db = Database()
    db.connect()
    yield db
    db.disconnect()

@pytest.fixture
def user_repository(database):
    """Fixture that depends on database fixture"""
    return UserRepository(database)

def test_create_user(user_repository):
    user = user_repository.create(name="Alice")
    assert user.id is not None

Read the full file on GitHub · 498 lines

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. 2d ago First seen · 498 lines · 35 tokens per session scan A 9961c5536f09

Subscribe to this mod's changes

python-testing is a skill published in the GitHub repository affaan-m/ECC (250,130 stars, last pushed today), licensed MIT. It adds 35 tokens to every session and 2,527 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.