marketplace/bundles/pm-dev-python/skills/pytest-testing/SKILL.md
Use when writing, reviewing, or debugging Python tests — covers pytest framework, AAA pattern, fixtures, parametrization, isolation, mocking, assertions, and coverage configuration. Activate for any Python testing task.
npx skillsauth add cuioss/plan-marshall pytest-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
REFERENCE MODE: This skill provides reference material for writing pytest tests. Load standards on-demand based on current task.
Execution mode: Reference library; load standards on-demand for Python testing tasks.
Prohibited actions:
unittest.TestCase for new tests; use plain pytest functionsos.chdir() without restoration (use monkeypatch.chdir())Constraints:
Activate when:
monkeypatch, unittest.mock.patch, state patchingFile: standards/testing-pytest.md (331 lines)
Load When:
Contents:
tmp_path, monkeypatch, _restore_cwd)capsys, capfd)Load Command:
Read standards/testing-pytest.md
| Topic | Rule |
|-------|------|
| File naming | test_<module>.py |
| Function naming | test_<behavior> — descriptive of what is tested |
| Structure | Arrange-Act-Assert (AAA) |
| Isolation | tmp_path for files, monkeypatch for state, autouse _restore_cwd |
| Fixtures | conftest.py for shared, function scope by default |
| Parametrize | @pytest.mark.parametrize for input variations |
| Exceptions | pytest.raises(ExcType, match="pattern") |
| Approximate | pytest.approx(value, rel=tolerance) |
| Output capture | capsys for Python, capfd for subprocess output |
| Script testing | subprocess.run with capture_output=True, text=True, timeout=30 |
# Via build system
python3 .plan/execute-script.py plan-marshall:build-pyproject:pyproject_build run --command-args "module-tests"
# Specific module
python3 .plan/execute-script.py plan-marshall:build-pyproject:pyproject_build run --command-args "module-tests pm-dev-python"
# With coverage
python3 .plan/execute-script.py plan-marshall:build-pyproject:pyproject_build run --command-args "coverage"
pm-dev-python:python-core - Core Python development patternsplan-marshall:dev-general-module-testing - Language-agnostic testing methodologytools
Plan-marshall-domain implementor of the ext-self-review-{domain} extension point. Surfaces deterministic candidates (regexes, user-facing strings, markdown sections, symmetric-pair functions, flag-guard pairs, contract sources, schema-bearing files) for pre-submission structural self-review.
development
Domain-invariant recipe for deliberate wide-scope simplification campaigns across a scope x thoroughness cell, with a T4+ relation-graph pre-deliverable
testing
A test skill for README generation
testing
A test skill with existing references