agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/python/py-testing/SKILL.md

py-testing

Skill0 starsChanged 2 months agoMITView on GitHub

Guides agents through authoring, isolating, and debugging Python tests using Pytest, fixtures, and mocks.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run and debug Python automated tests.

    line 11
  2. Distinctive:

    Use this skill when:

    line 14
  3. Very specific:

    Do not use for TypeScript tests.

    line 20
  4. Very specific:

    Do not use for linting; use py-lint-and-typecheck.

    line 21
  5. Very specific:

    If test_path is missing: run pytest in current directory or search tests/ directory.

    line 28
  6. Very specific:

    Never modify assert actual == expected values to force a broken test to pass.

    line 29
  7. Distinctive:

    Follow these numbered actions:

    line 32
  8. Distinctive:

    Read failure message and line numbers.

    line 36
  9. Very specific:

    Run pytest to confirm zero regressions.

    line 42
  10. Very specific:

    If test fails due to missing module: verify virtualenv or pip install -e .

    line 45
  11. Very specific:

    If test outputs stdout needed for debugging: add -s flag (pytest -s ...).

    line 46
  12. Distinctive:

    Stop and ask the user when:

    line 76
  13. Distinctive:

    Test requires cloud services or proprietary database credentials.

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Testing (Pytest)

Guides agents through executing, isolating, and debugging Python tests with pytest. Enforces clean fixture usage (conftest.py), parametrization, and mocking.

1. Purpose

Run and debug Python automated tests. A "Pytest Fixture" provides reproducible test dependencies. A "Parametrized Test" runs one test over multiple input/output pairs.

2. When to Use

Use this skill when:

  • Running Python test suites with pytest.
  • Filtering test runs by keyword (pytest -k "test_pattern").
  • Writing fixtures or mocking external APIs with unittest.mock.

3. When Not to Use

  • Do not use for TypeScript tests; use ts-testing.
  • Do not use for linting; use py-lint-and-typecheck.

4. Required Inputs

  • test_path: Path to test file or directory (e.g. tests/test_orders.py).
  • keyword_filter: Optional test function name or substring (-k).

5. Missing-Input Behavior

  1. If test_path is missing: run pytest in current directory or search tests/ directory.
  2. Never modify assert actual == expected values to force a broken test to pass.

6. Procedure

Follow these numbered actions:

  1. Action 1: Run Targeted Test
    • Execute: pytest <test_path> -k "<keyword>" -v
  2. Action 2: Inspect Failures & Tracebacks
    • Read failure message and line numbers.
  3. Action 3: Trace Root Cause to Implementation
    • Inspect the code file being tested.
  4. Action 4: Apply Fix & Re-run
    • Confirm targeted test passes.
  5. Action 5: Run Full Test Suite
    • Run pytest to confirm zero regressions.

7. Decision Rules

  • If test fails due to missing module: verify virtualenv or pip install -e . installation.
  • If test outputs stdout needed for debugging: add -s flag (pytest -s ...).

8. Output Format

Emit the report using this template:

### Pytest Execution Report: [Test File]

- **Command**: `pytest [path] -k "[filter]" -v`
- **Status**: [PASSED | FAILED]
- **Duration**: [e.g. 0.08s]

#### Summary
- Tests Run: [Count] | Passed: [Count] | Failed: [Count]

#### Resolution
- [Root cause and fix description]

9. Verification Checklist

  • Targeted pytest command executed with clean exit code 0.
  • No test assertions corrupted.
  • Full suite passes without regression.

10. Common Failures and Recovery

Failure SymptomCauseRecovery Action
Fixture 'db' not foundMissing conftest fixtureInspect conftest.py location and imports.
Test changes shared stateDirty fixture tear-downUse yield fixture with cleanup code after yield.

11. Stop or Escalation Conditions

Stop and ask the user when:

  • Test requires cloud services or proprietary database credentials.

12. Examples

Example 1: Successful Execution

Input:

File: tests/test_calc.py
Filter: test_divide

Output:

### Pytest Execution Report: tests/test_calc.py

- **Command**: `pytest tests/test_calc.py -k "test_divide" -v`
- **Status**: PASSED
- **Duration**: 0.04s

#### Summary
- Tests Run: 2 | Passed: 2 | Failed: 0

#### Resolution
- Fixed ZeroDivisionError by adding check in `calc.py`.

Example 2: Ambiguous or Missing Input

Input:

Run python tests.

Output:

### Pytest Execution Report: Halted - Ambiguous Target

- **Status**: Halted

Please specify the test file or function name you want to run.

Example 3: Expected Final Output

Output:

### Pytest Execution Report: tests/test_api.py

- **Command**: `pytest tests/test_api.py -v`
- **Status**: PASSED
- **Duration**: 0.22s

#### Summary
- Tests Run: 6 | Passed: 6 | Failed: 0

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.