python-testing

python-testing is a skill for Claude Code, Codex from Luohaothu/everything-codex. It costs 26 tokens per session (4,607 once invoked), scanned A, original, MIT.

A Python testing guide built around pytest, a Python test framework, and TDD, a method of writing a failing test before the code that makes it pass.

In plain words
What is it for?
Use it when adding or reviewing Python code, designing a test suite, or setting up testing. It covers fixtures, mocks, parameterized tests, the red-green-refactor cycle, and coverage requirements.
Why use it?
It gives a repeatable way to design tests, check behavior, and measure whether important code paths are covered.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding or reviewing Python code, designing a test suite, or setting up testing. It covers fixtures, mocks, parameterized tests, the red-green-refactor cycle, and coverage requirements.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/luohaothu/everything-codex/python-testing
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.

Any agent
npx skills add Luohaothu/everything-codex --skill python-testing
Clone the repo
git clone --depth 1 https://github.com/Luohaothu/everything-codex

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/luohaothu/everything-codex/python-testing/github.svg)](https://agentmods.dev/skills/luohaothu/everything-codex/python-testing)
Your own site
<a href="https://agentmods.dev/skills/luohaothu/everything-codex/python-testing"><img src="https://agentmods.dev/badge/skills/luohaothu/everything-codex/python-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-testing

Your own site · 80×15
<a href="https://agentmods.dev/skills/luohaothu/everything-codex/python-testing"><img src="https://agentmods.dev/badge/skills/luohaothu/everything-codex/python-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,607 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 215
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.00026 $0.04607
Opus 5.5 $0.00010 $0.01843
Sonnet 5.5 $0.00005 $0.00921
Haiku 4.5 $0.00003 $0.00461

Measured 1mo ago against content hash a32ca141a566, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-testing 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 1mo 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.

Makes network callslowCapability

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

response = requests.get("https://api.example.com")
docs/zh-CN/skills/python-testing/SKILL.md · 816 lines

How it starts

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

Python 测试模式

使用 pytest、TDD 方法论和最佳实践的 Python 应用程序全面测试策略。

何时激活

  • 编写新的 Python 代码(遵循 TDD:红、绿、重构)
  • 为 Python 项目设计测试套件
  • 审查 Python 测试覆盖率
  • 设置测试基础设施

核心测试理念

测试驱动开发 (TDD)

始终遵循 TDD 循环:

  1. 红:为期望的行为编写一个失败的测试
  2. 绿:编写最少的代码使测试通过
  3. 重构:在保持测试通过的同时改进代码
# Step 1: Write failing test (RED)
def test_add_numbers():
    result = add(2, 3)
    assert result == 5

# Step 2: Write minimal implementation (GREEN)
def add(a, b):
    return a + b

# Step 3: Refactor if needed (REFACTOR)

覆盖率要求

  • 目标:80%+ 代码覆盖率
  • 关键路径:需要 100% 覆盖率
  • 使用 pytest --cov 来测量覆盖率
pytest --cov=mypackage --cov-report=term-missing --cov-report=html

pytest 基础

基本测试结构

import pytest

def test_addition():
    """Test basic addition."""
    assert 2 + 2 == 4

def test_string_uppercase():
    """Test string uppercasing."""
    text = "hello"
    assert text.upper() == "HELLO"

def test_list_append():
    """Test list append."""
    items = [1, 2, 3]
    items.append(4)
    assert 4 in items
    assert len(items) == 4

断言

# Equality
assert result == expected

# Inequality
assert result != unexpected

# Truthiness
assert result  # Truthy
assert not result  # Falsy
assert result is True  # Exactly True
assert result is False  # Exactly False
assert result is None  # Exactly None

# Membership
assert item in collection
assert item not in collection

# Comparisons
assert result > 0
assert 0 <= result <= 100

# Type checking
assert isinstance(result, str)

# Exception testing (preferred approach)
with pytest.raises(ValueError):
    raise ValueError("error message")

# Check exception message
with pytest.raises(ValueError, match="invalid input"):
    raise ValueError("invalid input provided")

# Check exception attributes
with pytest.raises(ValueError) as exc_info:
    raise ValueError("error message")
assert str(exc_info.value) == "error message"

夹具

基本夹具使用

import pytest

@pytest.fixture
def sample_data():
    """Fixture providing sample data."""
    return {"name": "Alice", "age": 30}

def test_sample_data(sample_data):
    """Test using the fixture."""
    assert sample_data["name"] == "Alice"
    assert sample_data["age"] == 30

Read the full file on GitHub · 816 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. 1mo ago First seen · 816 lines · 26 tokens per session scan A a32ca141a566

Subscribe to this mod's changes

python-testing is a skill published in the GitHub repository Luohaothu/everything-codex (25 stars, last pushed 2mo ago), licensed MIT. It adds 26 tokens to every session and 4,607 once invoked, about $0.0001 per session on Opus 5.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-08-30.

Related

Other skills, from other repositories

cpp-testing

Use only when writing/updating/fixing C++ tests, configuring GoogleTest/CTest, diagnosing failing or flaky tests, or adding coverage/sanitizers.

affaan-m/ECC · 34 tokens

rust-testing

Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology.

affaan-m/ECC · 31 tokens

write-vibe-tests

Write or refactor Mistral Vibe tests with proper decoupling. Use when adding behavior coverage, testing ports/adapters, replacing brittle mocks, creating fakes, adding characterization tests before refactors, or changing tests under tests/ for vibe/core, vibe/cli, vibe/acp, tools, config, sessions, skills, hooks, MCP…

mistralai/mistral-vibe · 80 tokens

composing-matchers

Build compound Gomega assertions by combining matchers — And/SatisfyAll (all pass), Or/SatisfyAny (any pass), Not (negate), WithTransform to map the actual before matching, Satisfy for an ad-hoc predicate, HaveValue to dereference pointers/interfaces, HaveField for struct fields and method results, HaveEach for every…

onsi/gomega · 136 tokens

principle-test-behavior-not-implementation

Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change.

michael-denyer/pstack-claude · 50 tokens

spec-driven-tests

Rebuild a package's unit test suite around a behavior specification (SPEC.md) derived from the implementation, with every test citing a numbered rule ID. Use when asked to do a spec-driven test rebuild, write a SPEC.md for a package, repeat the state or store spec process (PRs.

tldraw/tldraw · 63 tokens