/python-plugin:python-pytestfrom python-plugin
Deep guidance for pytest. Use when writing tests, designing fixtures, parametrizing, configuring `[tool.pytest.ini_options]`, organizing conftest.py, debugging collection errors, picking plugins (pytest-xdist, pytest-asyncio, pytest-cov), or optimizing slow suites. Pairs with the unified `python` skill.
Ships in python-plugin. 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.
None: SKILL.md is the whole skill.
pytest is the only test runner. No unittest classes unless inheriting from a fixture framework that requires it.
[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src", "scripts"]
addopts = "-ra --strict-markers --strict-config"
xfail_strict = true
filterwarnings = ["error"]
--strict-markers + --strict-config catch typos in marker / option
names. filterwarnings = ["error"] makes warnings fail the suite (turn
specific ones into default::CategoryName).
tests/test_<module>.py mirroring source layout.def test_<behavior>(...). No camelCase.setUp/tearDown.tests/conftest.py.function (default), module, session. Wider
scope == faster but more shared state.@pytest.fixture
def tmp_db(tmp_path):
db = make_db(tmp_path / "x.db")
yield db
db.close()
monkeypatch for env / attribute swaps. tmp_path for isolated
filesystem. caplog for log assertions.@pytest.mark.parametrize(
("input_text", "expected"),
[
("foo", 3),
("hello", 5),
("", 0),
],
ids=["short", "word", "empty"],
)
def test_length(input_text: str, expected: int) -> None:
assert len(input_text) == expected
Always provide explicit ids for non-trivial params — default repr is
unreadable in failure output.
pytest.mark.skip — never run.pytest.mark.skipif(condition, reason=...) — conditionally skip.pytest.mark.xfail(strict=True) — expected failure; will fail the
suite if it unexpectedly passes (with xfail_strict = true).[tool.pytest.ini_options].markers so
--strict-markers accepts them.pytest-asyncio>=0.23 to dev deps.@pytest.mark.asyncio or set
asyncio_mode = "auto".pytest-xdist for parallel: pytest -n auto. Tests must be isolated
(no shared global state).pytest-cov for coverage: pytest --cov=src --cov-report=term-missing.| Goal | Command |
|---|---|
| Run one test | pytest tests/test_x.py::test_y |
| Re-run last failures | pytest --lf |
| Stop on first failure | pytest -x |
| Verbose w/ short tracebacks | pytest -v --tb=short |
| Drop into pdb on failure | pytest --pdb |
| Show slowest 10 | pytest --durations=10 |
| Filter by name | pytest -k "auth and not slow" |
| Filter by marker | pytest -m "not slow" |
If pytest fails before running anything ("collection error"):
python -c "import tests.test_x" to reproduce.pythonpath entry — add to [tool.pytest.ini_options].test_x.py in different dirs without
__init__.py clash. Add __init__.py to one or use unique names.What SKILL.md sets; muted values are Claude Code's defaults
python-plugin@cjhowe-us-marketplace is listed by cjhowe-us/marketplace — review the source before installing
npx claudepluginhub cjhowe-us/marketplace --plugin python-plugin6 skills in this plugin
/pythonUnified Python coding standard for projects in this workspace. Use this skill whenever reading, writing, editing, reviewing, or creating any `.py` file. Covers types (mypy --strict), lint/format (ruff), env + packaging (uv), tests (pytest), and publishing (PyPI). Per-tool deep dives live in sibling skills (`python-ruff`, `python-mypy`, `python-uv`, `python-pypi`, `python-pytest`) — load those for fine-grained guidance.
/python-mypyDeep guidance for mypy strict static typing. Use when configuring `[tool.mypy]`, debugging type errors, picking between `cast` / `assert isinstance` / TypeGuard, writing protocols vs ABCs, handling third-party libraries without stubs, dealing with pydantic plugin, silencing follow-imports for path-injected modules, or migrating an untyped codebase. Pairs with the unified `python` skill — load this one when the question is specifically about mypy.
/Other plugins' skills for the same job