/omniagents-python:testingfrom omniagents-python
Use when writing or reviewing Python tests: pytest suite architecture and gate tiers, fixtures and conftest layering, parametrize and subtests, mock / monkeypatch boundaries, httpx.MockTransport / respx and the remote-failure taxonomy, retry / circuit-breaker / idempotency assertions, flaky or order-dependent tests, sleep-based waits, time and randomness control, network hermeticity enforcement, pytest-asyncio / anyio, hypothesis property-based tests, testcontainers integration suites, syrupy snapshots, type-level tests, log and OpenTelemetry span assertions, coverage and mutation gates, memory and benchmark gates, LLM eval boundaries, or pytest configuration in pyproject.toml.
Ships in omniagents-python. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A test earns its place by failing when the behavior it protects breaks. Every
rule below serves that one property: a suite where each test would catch a
specific wrong implementation, and where a red run always means a real defect
— never a flake, never a stale mock, never an ordering accident. Tests are
production code. They pass the same type checkers and the same linters as
src/, and they are reviewed against the same bar.
This skill assumes Python 3.14+ and pytest 9+, familiarity with fixtures,
parametrize, pytest.raises, and unittest.mock, and is rules, not a
tutorial. This hub holds the tiers, the non-negotiables, and a routing table;
the detailed rules live in references/. Scope boundaries:
test-driven-development where installed; this skill governs what the
resulting tests look like.typings skill; async
runtime primitives from performance.Not every worthwhile check can be deterministic, and pretending otherwise is how a suite acquires muted alarms. Three gates, distinguished by what a red run means:
| Property | G1 blocking gate | G2 gated job | G3 scheduled canary |
|---|---|---|---|
| Runs on | every commit and PR | every PR, separate job | cron, or path-gated |
| Determinism | total — same input, same verdict | total verdict, noisy measurement | statistical; the verdict is a distribution |
| A red run means | a defect, always | a defect, always | investigate — never auto-blocks a merge |
| Flake policy | zero; a flake is a bug to remove | zero on the verdict, tolerance on the number | expected; report bands, not booleans |
| Budget | seconds | minutes | unbounded — it is off the merge path |
| Members | unit tests, type-level tests | integration tests, memory limits, benchmarks, mutation runs | LLM evals, fuzzing, dependency-upgrade canaries, race stress |
Every gate names its tier and its pain. A test in the wrong tier is worse than a missing test: a noisy check on the blocking gate gets muted within two sprints and protects nothing afterwards, while a deterministic check exiled to a nightly job stops being read at all. Place a new kind of test before you write it.
The non-negotiables below bind G1. G2 relaxes the runtime budget and the measurement only — a benchmark number varies, its pass/fail rule must not. G3 is the only tier where red means "investigate" rather than "defect," which is precisely why nothing in it may block a merge.
The tiers restate Google's test-size axis: G1 ≈ small tests (hermetic,
single-process), G2 ≈ medium and large tests (resource-gated), and G3 covers
nondeterministic subjects the size taxonomy never named. Size is distinct
from scope — the unit-vs-integration routing lives in references/unit.md
and references/integration.md.
src/. Every test function is
annotated (-> None), every fixture carries its real return type
(Iterator[X] for yield fixtures), and mypy/pyright strict includes
tests/. Lint relaxations are a scoped per-file-ignores list
(S101, PLR2004), never a blanket exclude of the test tree, and
ruff's flake8-pytest-style (PT) rules stay on.filterwarnings = ["error"]. Each allowlisted
warning names its source and its removal condition. A deprecation that can
scroll past unread is a future breakage with a disabled alarm.strict = true — the pytest 9 umbrella covering
strict_config, strict_markers, strict_parametrization_ids, and
strict_xfail, so a separate xfail_strict = true is redundant. An xfail
that unexpectedly passes is a finding, not a bonus. On pytest 8, spell the
set out: --strict-markers --strict-config plus xfail_strict = true.random.Random for randomness. Determinism is a mechanism, not a
convention — --disable-socket makes the network rule fail closed (see
references/determinism.md). A test that cannot flake is one that never
needs a retry plugin — retrying flaky tests is rejected as a fix on G1
and G2 alike.pytest -n auto (xdist). No test reads
state another test wrote; anything session-scoped is immutable or
per-worker. Same caveat as pytest-timeout: pytest-xdist 3.8.0 publishes no
Python 3.14 classifier — verify it against the pinned interpreter before
relying on it in a 3.14+ project (checked 2026-07-26).test_<subject>_<scenario>_<expected>
(test_fetch_user_client_error_is_not_retried). Arrange, act, assert —
separated by blank lines. No branching or loops around assertions; a loop
over cases is a parametrize table that lost its ids.pytest.raises takes the narrowest type and match=. A bare
pytest.raises(Exception) passes when the wrong error is raised from the
wrong line. Assert on excinfo.value attributes when the error carries
structured context.assert client.push.called alone survives a mutant that
pushes the wrong payload; assert the payload. The exception: when the
interaction is the contract ("sends exactly one email"), the call count
is the outcome — assert it exactly, with its arguments.Full rules and rationale: references/unit.md.
tests/unit/ from tests/integration/ — real
infrastructure behind the registered integration marker, separate CI job.conftest.py by blast radius: a fixture lives in the narrowest file
that covers its users._privates.| Symptom or question | Read |
|---|---|
| Retry/backoff schedule, circuit breaker, idempotency-key proof | references/resilience.md |
| Freeze time in an async test; sleep, clock, or rng in a test | references/determinism.md |
| Flaky or order-dependent tests; real network, disk, env access | references/determinism.md |
| Real Postgres or mock the repository? | references/doubles-and-boundaries.md + references/integration.md |
| Mock vs fake vs stub; patch target choice; autospec | references/doubles-and-boundaries.md |
| Tempted to patch the subject's own internal helper | references/doubles-and-boundaries.md |
| Which remote failure modes need tests | references/doubles-and-boundaries.md |
| Where do factories live; fixture scope, autouse, chains | references/fixtures-and-factories.md |
| testcontainers, migrations, Pact / schemathesis contracts | references/integration.md |
| Unit/integration split; parametrize ids; subtests; snapshots | references/unit.md |
assert_type pins and other type-level tests | references/unit.md |
| Hypothesis vs parametrize; finding properties; stateful models | references/property-based.md |
| Chasing 100% coverage; what runs in CI; pytest config | references/gates-and-ci.md |
| Benchmark or memory gates; mutation testing | references/gates-and-ci.md |
| Testing an LLM-backed function; judge scores flicker | references/evals.md |
time.sleep(0.5) before checking an async result;
slower CI turns it red. Replace with a deadline-bounded condition wait.Mock() drift: no spec_set, so interface changes never break
the test — it passes forever, protecting nothing.parametrize case no assertion
distinguishes.tests/: the suite silently becomes
the least-reviewed, least-typed code in the repo.-p randomly.@flaky markers instead of removing
the nondeterminism source. The flake is a bug — in the test or the code.pytest-benchmark disables itself under
-n auto, so the job is green because nothing was measured.BatchSpanProcessor: spans export on a
timer, so the assertion races the flush — sleep-then-assert in a costume.assert_type against whatever the
checker infers today, breaking on the next checker improvement while
protecting no real contract.parametrize vs subtests → known at collection time → parametrize with
ids; discovered at runtime from data → subtests.pytest-asyncio vs anyio → asyncio-only → pytest-asyncio; Trio or dual
backend → anyio. Never enable both plugins' auto modes.xfail vs skip → xfail (strict) for known bugs; skip only for genuinely
inapplicable environments, via skipif.test-driven-development (where installed). This skill defines the
quality bar of the artifacts that process produces.references/doubles-and-boundaries.md, or WireMock's real-socket faults in
an integration test — and asserting your retry, breaker, and idempotency
code answers correctly. Tools that operate on containers or clusters
(pumba, chaos-mesh) have no pytest surface by design; chaostoolkit is
additionally unmaintained.cProfile sessions belong to this plugin's performance skill, which owns
measurement and runtime shape. This skill owns only what a suite can
assert: a memory ceiling, a leak check, a benchmark comparison.
Discovering why a number moved is the other skill's job.pyproject.toml is; the reference block in
references/gates-and-ci.md is the shape to converge on, not a file to
copy blindly.This skill is project policy, not a complete upstream reference: verify version-sensitive behavior (pytest ini options, hypothesis profiles, plugin loop-scope defaults) against primary docs — prefer Context7 MCP; otherwise web search restricted to official sources. Tooling versions were verified against PyPI and official docs on 2026-07-26; each reference file ends with its own sources and a freshness note, including the packages checked and rejected for its area.
references/determinism.md (opens in a new tab)references/doubles-and-boundaries.md (opens in a new tab)references/evals.md (opens in a new tab)references/fixtures-and-factories.md (opens in a new tab)references/gates-and-ci.md (opens in a new tab)references/integration.md (opens in a new tab)references/property-based.md (opens in a new tab)references/resilience.md (opens in a new tab)references/unit.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Trigger for test files (test_*.py, conftest.py), writing unit or integration tests, adding a regression test for a bugfix, test-only diffs, flaky tests, sleep in tests, unseeded randomness, mock or patch target choices, autospec, fixture scope / autouse choices, async test hangs, mutation testing (mutmut), xdist parallelization, filterwarnings, tmp_path / env-var isolation, caplog / capsys log assertions, test data factories (polyfactory), Pact / schemathesis contract testing, assert_type / pytest-mypy-plugins, benchmark or performance-regression gates (pytest-benchmark, codspeed), memory limits / leak detection (memray), tests hitting the real network, deadlocks or thread-race stress, fuzzing, chaos or fault-injection requests, LLM / agent eval suites (deepeval), or pytest config edits.
inheritbash6 skills in this plugin
/docstringsUse when writing or reviewing Python docstrings for public modules, classes, functions, methods, properties, generators, overloads, doctest examples, or generated Sphinx API documentation, especially when choosing NumPy vs Sphinx style or deciding which Parameters, Returns, Yields, Raises, Warns, Attributes, Notes, See Also, and Examples sections belong./library-patternsUse when writing or reviewing Python that wraps a network service or authors a client SDK: client construction, async lifecycle, granular timeouts, retry policy, idempotency keys, structured exception hierarchies, per-request overrides, structured outputs with Pydantic, streaming via async context managers, request-id propagation, or pagination./Other plugins' skills for the same job
npx claudepluginhub gao-hongnan/omniagents --plugin omniagents-python