Pytest runner

From excatt/superclaude-plusplus · View interactive version

Pytest runner is an AI agent skill from the GitHub repository excatt/superclaude-plusplus. Execute and analyze pytest-based tests. Includes coverage reports, failure analysis, and fixture debugging.

How to use this skill

Skill file

Pytest Runner Skill

Purpose

Execute and analyze tests for Python projects.

When to Use

Execution Modes

1. Quick Test

pytest -x -q
# Stop at first failure, minimal output

2. Full Test with Coverage

pytest --cov=src --cov-report=term-missing --cov-report=html
# Full test suite + coverage report

3. Specific Test

pytest tests/test_api.py::test_create_user -v
# Run specific test only

4. Failed Only

pytest --lf
# Re-run only last failed tests

Output Format

All Pass

๐Ÿงช PYTEST RESULTS
=================

โœ… All tests passed!

๐Ÿ“Š Summary:
   Tests: 47 passed
   Time: 3.2s
   Coverage: 87%

๐Ÿ“ˆ Coverage by Module:
   src/api.py        92%
   src/models.py     95%
   src/utils.py      78%  โš ๏ธ
   src/db.py         85%

With Failures

๐Ÿงช PYTEST RESULTS
=================

โŒ 3 tests failed

๐Ÿ“Š Summary:
   Tests: 44 passed, 3 failed
   Time: 4.1s

๐Ÿ”ด Failures:

1. test_api.py::test_create_user_invalid_email
   โ”œโ”€ Expected: ValidationError
   โ””โ”€ Got: None

   ๐Ÿ’ก Fix: Check email validation logic
   ๐Ÿ“ Location: src/api.py:45

2. test_db.py::test_connection_timeout
   โ”œโ”€ Expected: TimeoutError after 5s
   โ””โ”€ Got: Hung indefinitely

   ๐Ÿ’ก Fix: Verify DB connection timeout setting

3. test_utils.py::test_parse_date
   โ”œโ”€ Expected: datetime(2024, 1, 15)
   โ””โ”€ Got: ValueError

   ๐Ÿ’ก Fix: Check date format parsing logic

Coverage Analysis

Minimum Thresholds

coverage:
  minimum: 80%      # Overall minimum
  critical_paths:
    - src/api.py: 90%
    - src/auth.py: 95%
    - src/models.py: 85%

Uncovered Lines Report

๐Ÿ“‹ Uncovered Code:

src/utils.py (78% covered):
   Lines 45-52: Error handling branch
   Lines 78-85: Edge case for empty input

   ๐Ÿ’ก Tests needed:
   - test_parse_with_empty_input()
   - test_parse_with_invalid_format()

Fixture Analysis

Fixture Dependencies

๐Ÿ“ฆ Fixture Graph:

db_session
  โ””โ”€โ†’ test_user
      โ””โ”€โ†’ authenticated_client
          โ””โ”€โ†’ admin_client

โš ๏ธ  Warning: Deep fixture chain (4 levels)
    โ†’ Verify test isolation

Slow Fixtures

โฑ๏ธ  Slow Fixtures:

| Fixture | Avg Time | Usage |
|---------|----------|-------|
| db_session | 0.8s | 32 tests |
| redis_client | 0.5s | 12 tests |
| mock_api | 0.3s | 8 tests |

๐Ÿ’ก Optimization: Consider changing db_session to module scope

Integration

# Pre-commit hook
pytest --co -q && pytest -x

# CI pipeline
pytest --cov --cov-fail-under=80 --junitxml=report.xml

# Watch mode (with pytest-watch)
ptw -- --lf

Commands

| Command | Description |

|---------|-------------|

| /pytest | Run all tests |

| /pytest --quick | Quick test (-x -q) |

| /pytest --cov | Include coverage |

| /pytest --failed | Re-run failed only |

| /pytest [path] | Run specific path |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.