
Python Testing
This covers the essentials of pytest-based testing with a strong TDD bent. You get fixtures with different scopes, parametrization patterns, mocking with unittest.mock, and the red-green-refactor cycle baked into the workflow. It pushes for 80% coverage as standard and 100% on critical paths, which is reasonable. The examples are practical: database setup/teardown, API auth headers in conftest.py, running tests by markers to skip slow integration tests. If you're building Python projects and want a reference that doesn't just show syntax but actually demonstrates when to use module-scoped fixtures versus function-scoped ones, this gets you there without the usual tutorial bloat.
- skills.sh installs
- 6K
- GitHub stars
- 300.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add affaan-m/ecc --skill python-testing --agent claude-codeInstalls into .claude/skills of the current project.
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:
- RED: Write a failing test for the desired behavior
- GREEN: Write minimal code to make the test pass
- 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 --covto measure coverage
pytest --cov=mypackage --cov-report=term-missing --cov-report=html
pytest Fundamentals
Basic Test Structure
import pytest
Sponsors
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Testing & QA, Python
- First seen
- Jul 14, 2026
More from affaan-m/ecc
All 263- Strategic Compact6K
- Design System6K
- Browser Qa6K
- Springboot Security6K
- Search First6K
- Nextjs Turbopack6K
- Brand Voice6K
- Jira Integration6K
- Laravel Tdd6K
- Fastapi Patterns6K
- Remotion Video Creation6K
- React Patterns5.9K
- Perl Security5.9K
- Kotlin Coroutines Flows5.9K
- React Performance5.9K
- Kotlin Patterns5.9K
- Architecture Decision Records5.9K
- Deployment Patterns5.8K
- React Testing5.8K
- Pytorch Patterns5.8K
- Hexagonal Architecture5.8K
- Flutter Dart Code Review5.8K
- Frontend A11y5.8K
- Error Handling5.8K