3.8 KiB
3.8 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. Use when you need best-practice guidance and source links for core pytest, FastAPI testing, and SQLAlchemy testing. | 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).
Reference Map
Use this map to open only the reference that matches your immediate need.
- Core pytest practices and command patterns: pytest-docs.md
- Naming conventions and hierarchy organization: naming-and-organization.md
- FastAPI-specific testing patterns: fastapi-testing.md
- SQLAlchemy-specific testing patterns: sqlalchemy-testing.md
Baseline Best Practices
These are stable defaults regardless of stack:
- 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.
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
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.
- Recommended structure, naming, fixture, and marker decisions.
- Exact validation commands.
- Relevant source-doc links for any non-trivial recommendation.
- Risks, assumptions, or open questions.