# Build Python Tests with pytest TDD

Python teams often need consistent tests, coverage, and reports without losing TDD discipline. This skill provides pytest-focused workflows, examples, and reporting guidance for Claude, Codex, and Claude Code.

## Install

```bash
npx skillstore add joseph obrien/89jobrien-tdd-pytest
```

## Metadata

- Status: approved
- Slug: 89jobrien-tdd-pytest
- Version: 1.0.1
- Author version: 1.0.1
- Skillstore revision: r1
- Version status: valid
- Tree hash: 755430fc9fe77334cc945cc7c838eb4e21d48777ead29d429922bc3264df508c
- Author: Joseph OBrien
- GitHub username: 89jobrien
- License: MIT
- Repository: https://github.com/89jobrien/steve/tree/main/steve/skills/tdd-pytest
- Ref: c4037264bbd363c572662d6154a3ab28f5ca4f53
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 81
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/89jobrien-tdd-pytest
- Manifest: https://skillstore.pages.dev/api/skills/89jobrien-tdd-pytest/manifest

## Capabilities

- Guides Red-Green-Refactor workflows for Python features.
- Suggests pytest file, function, class, and fixture naming conventions.
- Provides examples for fixtures, parametrization, async tests, and exception assertions.
- Documents uv-based pytest commands for files, filters, verbosity, traceback style, and coverage.
- Outlines pytest and coverage settings for pyproject.toml.
- Defines a local testing report format with results, coverage, findings, and evidence.

## Use Cases

- Add tests before implementation: Plan failing pytest cases first, then implement only enough behavior to pass them.
- Audit an existing test suite: Review pytest files for naming, fixture quality, coverage evidence, and missing edge cases.
- Standardize pytest configuration: Create practical pyproject.toml settings for discovery, markers, warnings, and coverage reporting.

## Prompt Templates

### Start a TDD cycle

```
Use the tdd-pytest workflow for this Python feature. First propose the smallest failing pytest case, then describe the minimal implementation needed to pass it.
```

### Write targeted tests

```
Write pytest tests for this behavior. Include normal cases, edge cases, and one failure case. Keep the tests focused and explain why each test exists.
```

### Audit test quality

```
Audit these pytest tests for clarity, fixture design, parametrization, missing assertions, and coverage gaps. Return prioritized recommendations with file and line references.
```

### Prepare a test report

```
Summarize the pytest run, coverage results, failures, skipped tests, and recommended fixes in TESTING_REPORT.local.md format. Include command evidence and priority levels.
```

## Limitations

- It does not replace project-specific test design decisions.
- Command examples assume uv, pytest, and related plugins are installed.
- Coverage thresholds and markers must be adapted to each repository.
- It cannot verify test behavior without access to the target code and dependencies.

## Best Practices

- Write the smallest failing test before changing production code.
- Run focused tests first, then run the broader suite with coverage.
- Keep reports local and include clear evidence for each recommendation.

## Anti Patterns

- Writing broad tests that do not verify specific behavior.
- Changing implementation before confirming the test fails for the right reason.
- Using shared fixtures that hide setup details or make failures unclear.

## Security Audit

- Audited at: 2026-07-05T13:54:55.573\+00:00
- Summary: All static findings were markdown formatting or pytest documentation false positives, not executable Ruby or shell backtick execution. I found no prompt injection, data exfiltration intent, or malicious behavior in SKILL.md.

## Stats

- Views: 239
- Downloads: 14
- Favorites: 0
- Popularity score: 0
