No slash command · from ceh-python-library
Load this skill when writing pytest tests for a Python library: unit tests, public-API tests, fixtures, and what to mock versus test for real. Trigger on a test file created or modified.
Ships in ceh-python-library. 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.
Framework: pytest. Add pytest-asyncio (asyncio_mode = "auto" in pyproject.toml) only when
the library has async code
Write library tests against the public API at the lowest tier that can show the behavior, with no I/O. Done when each test asserts one behavior and the suite touches no network or filesystem.
tests/unit/ or tests/api/ by whether it reaches private modules or imports the
package as a consumer would.your_library/
└── tests/
├── unit/ # Isolated — no I/O, mock all external dependencies
├── api/ # Exercise the public package API as a consumer would import it
└── conftest.py # Shared fixtures and mock factories
Test files mirror source structure. Naming: test_<what>_<expected_behavior>.py. One logical behavior per test.
Test against the public API surface (import your_library), not private modules — tests that reach
into _private internals lock in implementation details and break on every refactor.
class TestRetryPolicy:
def test_backoff_grows_exponentially(self):
policy = RetryPolicy(base=1.0, factor=2.0)
assert [policy.delay(n) for n in range(3)] == [1.0, 2.0, 4.0]
import your_library
def test_public_entry_point_is_importable():
assert callable(your_library.parse_duration)
assert your_library.parse_duration("1h") == timedelta(hours=1)
unittest.mock or pytest-mock.A floor for finding blind spots, not a goal. Below the number, look for the untested regions. Reaching it proves nothing and is never a reason to add tests.
| Area | Floor |
|---|---|
| Library package | 80% |
| Public API and core logic | 95% |
uv run pytest --cov=your_library --cov-report=term-missing
This skill covers the tooling — runner, fixtures, mocking, coverage. It does not decide which inputs and cases a test should cover. Before writing the cases:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-python-library3 skills in this plugin
/configure-python-library-envLoad this skill when setting up a Python library's environment or code style: uv dependencies, pyproject.toml, type hints, docstrings, naming, ruff/mypy. Trigger on a pyproject.toml edit or a uv command./publish-python-libraryLoad this skill when packaging, versioning, or publishing a Python library: build backend, src/ layout, wheels, PyPI, the public API in __init__.py / __all__, deprecations, semver. Trigger on a build config or __all__ edit, a changed public signature, or a uv build run.Other plugins' skills for the same job