/python:python-testingfrom python
Use when you write, fix, review or debug Python tests (test_*.py, conftest.py, pytest config), including flaky, slow or hanging tests, tests that sleep, mock, patch, hit the network or share fixtures. pytest, fakes, hypothesis.
Ships in 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.
make test runs the suite in parallel from the start (pytest-xdist -n auto, pytest-randomly). Concurrency safety: isolate per-worker resources with worker_id, tmp_path, and avoid shared mutable state or process-global changes. Every test passes under both: shared state and order dependence are bugs, not flakes.assertpytest 9 with its native [tool.pytest] table and strict = true (an unknown marker or config key, a duplicate parametrize id and an unexpectedly passing xfail fail the run). No unittest.TestCase, no assertion libraries: pytest rewrites assert a == b into a diff. pytest.raises(Error, match="...") for exceptions, pytest.approx for floats. Tests are type-checked and linted like the code they test; they skip docstrings (Google 3.8.2.1).
test_parse_rejects_negative_count (Google 3.16.2). One behaviour per test; arrange, act, assert separated by a blank line.id (pytest.param(..., id="surrounding-space")). A case that needs different setup or assertions is its own test.@pytest.mark.parametrize with explicit ids without losing test scenarios or branch coverage.@pytest.mark.xfail(reason="...", strict=True) (or raises=ExpectedException). With strict=True, XPASS turns red once fixed, ensuring the driver removes the marker after fixing the source code.tmp_path for every file, monkeypatch.setenv/monkeypatch.chdir for process state, never a real home, cwd or env.Read references/PATTERNS.md for the config block and worked tests (parametrize and compacting, xfail reproduction, worker isolation, fakes, injected clock, async, hypothesis, snapshot, HTTP), all run on CPython 3.14.
make_order(customer=vip)), so each test states the fields it cares about. A fixture depends on at most two others; one that returns an object graph is a factory in disguise.conftest.py only when a second module needs them.DEFAULT_EMAIL = "[email protected]"), never random or faker unless randomness is under test; hypothesis owns generated data.assert_called_with.mock.patch of our own modules. Patching reaches into implementation details and breaks on every rename; a patch target is a seam the code should take as a parameter. monkeypatch is for process boundaries only (env, cwd, sys.argv). unittest.mock.create_autospec is a last resort for a third-party object with no fake and no cheap real one.tmp_path and the real filesystem, httpx.MockTransport for an HTTP client, SQLite in memory or a throwaway database for SQL, a real subprocess for process code.now: Callable[[], datetime], and sleep for backoff) and pass a fake that the test advances. time-machine only for code you do not own that reads the clock itself.time.sleep or asyncio.sleep to wait for something to happen: await the event, the task or the fake's call.async def test_... (pytest-asyncio, asyncio_mode = "auto"); bound waits with asyncio.timeout inside the test.parse(format(x)) == x), never an unexpected exception, invariants. A failure hypothesis found becomes an @example(...) on the test, committed.pytest --snapshot-update writes __snapshots__/, and snapshot diffs are reviewed like code. Scrub ids and timestamps before comparing.@pytest.mark.integration, are deselected by default and run via make test-integration.repo-standard, Local gate): make check until the full suite takes minutes. Note its wall time in the repo's AGENTS.md; when it reaches minutes, add a make check-fast target (lint, types plus the fast tests) that agents and the guard's stop hook run instead, while CI runs everything.pytest-timeout with timeout = "300" in config, several times the slowest legitimate test (pytest --durations=15; CI runners are slower than a laptop). Raise it per test with @pytest.mark.timeout(n) only with a reason. Without it a hung test holds the job until the forge kills it, with no traceback.pytest-cov, branch coverage) is reported by make test, never gated there. A coverage floor, where a repo has one, runs in CI's full tier (ci-cd, Two tiers) and is never lowered to make a change pass.[tool.pytest] and [tool.pytest.ini_options] in one file is an error; plugin options under [tool.pytest] are still strings (timeout = "300", not 300).-n auto in addopts, -p no:xdist fails on the unknown -n; debug serially with -n0, which also brings back pdb and print output.Using --randomly-seed=N in the header; rerun with that flag to reproduce an order-dependent failure.tmp_path, monkeypatch) in a @given test with a FailedHealthCheck, since they are not reset between examples: build the state inside the test.session-scoped fixture runs once per xdist worker, not once per run; anything it creates (ports, directories, databases) must be unique per worker (worker_id fixture).markers.What SKILL.md sets; muted values are Claude Code's defaults
4 skills in this plugin
/fastapiUse when testing, adding or changing anything in a FastAPI app: TestClient tests, an endpoint or router, request validation, a Pydantic schema, settings from the environment, an auth or API-key dependency, middleware. House rules for FastAPI./python-developmentUse when you write or change Python (.py), pyproject.toml or a ruff config: a feature, fix, refactor or review, even a one-line bug fix, and even when conventions are not mentioned. House rules: typing, errors, uv, ruff, mypy --strict./sqlalchemyUse when defining SQLAlchemy models, writing queries, managing sessions and transactions, loading relationships, adding a migration, or tuning performance, sync or async. SQLAlchemy 2.x ORM and Core.npx claudepluginhub giocaizzi/harness --plugin python