Skip to content
affaan-m avatar

Python Testing

Pytest testing patterns covering TDD, fixtures, parametrization, mocking, and coverage targets for Python projects.

CCM score
65 of 100
skills.sh installs
14.3K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the red-green-refactor TDD cycle, pytest assertions, and exception testing with pytest.raises
  • Includes fixture patterns (scopes, setup and teardown, parameterized fixtures, autouse, and conftest.py sharing) plus parametrization and custom markers
  • Sets an 80% coverage target with 100% required on critical paths, measured with pytest --cov
  • Designed for Python developers writing new code or reviewing test suites and coverage in pytest projects

Install

$ npx -y skills add affaan-m/ecc --skill python-testing -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Python Testing Patterns

Comprehensive testing strategies for Python applications using pytest, TDD methodology, and best practices.

When to Activate

  • Writing new Python code (follow TDD: red, green, refactor)
  • Designing test suites for Python projects
  • Reviewing Python test coverage
  • Setting up testing infrastructure

Core Testing Philosophy

Test-Driven Development (TDD)

Always follow the TDD cycle:

  1. RED: Write a failing test for the desired behavior
  2. GREEN: Write minimal code to make the test pass
  3. REFACTOR: Improve code while keeping tests green
# Step 1: Write failing test (RED)
def test_add_numbers():
    result = add(2, 3)
    assert result == 5

# Step 2: Write minimal implementation (GREEN)
def add(a, b):
    return a + b

# Step 3: Refactor if needed (REFACTOR)

Coverage Requirements

  • Target: 80%+ code coverage
  • Critical paths: 100% coverage required
  • Use pytest --cov to measure coverage
pytest --cov=mypackage --cov-report=term-missing --cov-report=html

pytest Fundamentals

Basic Test Structure

import pytest

Details

Repository
github.com/affaan-m/ecc
Categories
Testing & QA, Python
First seen
Jul 14, 2026

Questions

What does the python-testing skill help an agent do?

The python-testing skill gives an agent strategies for testing Python code with pytest, following the TDD cycle of red, green and refactor. It covers fixtures, mocking, parametrization and coverage requirements, including a target of 80% or more code coverage.

How do I install the python-testing skill?

Run npx -y skills add affaan-m/ecc --skill python-testing -y in your project to install it. Once installed, the agent can apply pytest fixtures, mocks, parametrized tests and coverage checks when you write Python tests.

Where does python-testing rank in its category?

On Claude Marketplaces it sits in the Testing & QA category, where it ranks in the top 50. Other skills in that category include tdd, test-driven-development, webapp-testing and break-ui.

Which Python test patterns does this skill cover?

The skill covers basic pytest test structure, assertions, fixtures with setup and teardown, fixture scopes, parametrized tests and custom markers for selecting tests. It also includes mocking and patching examples for isolating external calls.

More from affaan-m/ecc

All 257

Similar to Python Testing

More Testing & QA