6.6 KiB
name, description, argument-hint, x-personal-mcp
| name | description | argument-hint | x-personal-mcp | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pytest-scaffolding | Reference hub for pytest suite structure, naming, markers, and stack-specific testing patterns. Optimized for progressive discovery so naming and hierarchy guidance are loaded first when shaping or reorganizing tests. | Target scope plus stack details (pure Python, FastAPI, SQLAlchemy sync, SQLAlchemy async, or mixed) |
|
Pytest Scaffolding
This skill is a collection of best-practice references and source-documentation links for building and maintaining pytest suites.
Use it to quickly find the right guidance for:
- Baseline pytest structure and marker strategy.
- Naming conventions and test hierarchy organization.
- FastAPI route, dependency override, and lifespan testing patterns.
- SQLAlchemy transaction and session testing patterns.
Repository defaults:
uv run pytestis the canonical invocation.- pytest settings live in
pyproject.tomlunder[tool.pytest.ini_options]. - strict marker checking is expected (
--strict-markers).
Progressive Discovery Start
Use this load order by default so guidance stays targeted and naming conventions are pulled in early:
- Classify intent first: naming and organization, baseline pytest mechanics, FastAPI testing, SQLAlchemy testing, or mixed.
- For create/restructure/rename tasks, load naming-and-organization.md first.
- Load pytest-docs.md next for fixture and marker defaults.
- Load at most one stack-specific reference unless the request is explicitly mixed stack.
- If confidence is low after two references, ask one clarifying question before loading more.
Load budget defaults:
- Single-stack task: 1 to 2 references.
- Mixed-stack task: up to 3 references.
- Avoid loading all references unless the user explicitly asks for a broad audit.
Intent Router
Open only the reference that matches the immediate task.
- Naming, file layout, discovery prefixes, class/function naming: naming-and-organization.md
- Fixture layering, marker policy, collect-only and fast-path commands: pytest-docs.md
- Route tests, dependency overrides, lifespan handling: fastapi-testing.md
- Session and transaction fixtures, async ORM behavior: sqlalchemy-testing.md
Naming Pull-In Triggers
Always consult naming-and-organization.md before recommending structure when any of these are true:
- New tests are being added.
- Existing tests are being reorganized or renamed.
- The request mentions conventions, readability, hierarchy, or discoverability.
- The task introduces parametrization where case naming affects failure readability.
Baseline Best Practices
These are stable defaults regardless of stack:
- Apply pytest naming and hierarchy conventions first so discovery and ownership stay predictable; see naming-and-organization.md.
- Mirror
src/intotests/so ownership and coverage are obvious. - Keep fixtures explicit and layered (
tests/conftest.pyglobally, subtreeconftest.pyfor domain-specific fixtures). - Register markers up front (
unit,integration,smoke,slow,external) and keep strict marker checks enabled. - Separate fast feedback (
-m unit) from broader integration/external lanes. - Validate structure early with collection checks before expanding assertions.
- Prefer behavior-first tests that exercise real code paths and concrete inputs over patching internals.
- Use monkeypatching, mocks, and fakes extremely sparingly, only when no practical real-input alternative exists, and only after explicit user confirmation.
Universal Test Double Policy (Repo-Local Placement)
Treat this policy as universal guidance for test authoring, while it is documented in this repository-local skill file for now.
Apply this policy whenever a test change introduces a fake collaborator or patched behavior:
- Attempt a real-input, real-object test design first.
- If that approach is impractical, explain why and request user confirmation before adding monkeypatching, mocks, or fakes.
- Keep any approved test double narrowly scoped and document the exact boundary it replaces.
- Revisit approved test doubles when implementation seams improve so they can be removed.
Stack-Specific Guidance
- For FastAPI, prefer dependency overrides and clear lifecycle handling; see fastapi-testing.md.
- For SQLAlchemy, prefer transaction-safe session fixtures and explicit async loading strategy; see sqlalchemy-testing.md.
- For naming and tree organization, use the conventions in naming-and-organization.md.
Source Documentation Entry Points
Primary upstream docs are curated in each reference page. Start with:
- Pytest good practices: pytest docs
- Pytest fixtures: fixture how-to
- Pytest markers: marker examples
- FastAPI testing: FastAPI testing tutorial
- SQLAlchemy transaction testing: SQLAlchemy external transaction pattern
- Pytest monkeypatch usage and limits: monkeypatch how-to
Quick Validation Commands
Use these commands to check structure and execution lanes:
uv run pytest --collect-only -quv run pytest -m unit -quv run pytest -m "not external" -quv run pytest -q
Output Contract
When this skill is applied, return:
- Which references were consulted.
- The discovery path used (intent classification, load order, and why).
- Recommended structure, naming, fixture, and marker decisions.
- Concrete naming outcomes: file/module naming pattern, class usage decision, and any parametrization
idsconventions. - Exact validation commands.
- Relevant source-doc links for any non-trivial recommendation.
- Risks, assumptions, or open questions.
- Explicit confirmation status if monkeypatching, mocks, or fakes were requested or used.