python-testing

Solid

Python testing strategies using pytest, TDD methodology, fixtures, mocking, parametrization, and coverage requirements.

Testing & QA 496 stars 41 forks Updated 1 months ago MIT

Install

View on GitHub

Quality Score: 86/100

Stars 20%
90
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 ```python # 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 ```bash pytest --cov=mypackage --cov-report=term-missing --cov-report=html ``` ## pytest Fundamentals ### Basic Test Structure ```python import pytest def test_addition(): """Test basic addition.""" assert 2 + 2 == 4 def test_string_uppercase(): """Test string uppercasing.""" text = "hello" assert text.upper() == "HELLO" def test_list_append(): """Test list append.""" items = [1, 2, 3] items.append(4) assert...

Details

Author
vibeeval
Repository
vibeeval/vibecosystem
Created
2 months ago
Last Updated
1 months ago
Language
C#
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category