python-testing

Solid

Stub-Driven TDD and layer boundary testing with pytest. Use when writing tests, deciding what to test, testing at component boundaries, or implementing test-driven development.

Testing & QA 38 stars 3 forks Updated today MIT

Install

View on GitHub

Quality Score: 87/100

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

Skill Content

# Testing with pytest Stub-Driven TDD and layer boundary testing patterns for Python applications. ## Core Principle: Stub-Driven TDD Test at component boundaries, not internal implementation: ``` Router → Service → Repository → Entity → Database ↓ ↓ ↓ ↓ Test Test Test Test ``` Follow the **Stub → Test → Implement → Refactor** workflow: 1. **Stub** - Create function signature with `pass` 2. **Test** - Write test for expected behavior 3. **Implement** - Make test pass 4. **Refactor** - Clean up code ```python # 1. Stub def calculate_discount(total: Decimal) -> Decimal: pass # 2. Test def test_discount_for_large_order(): result = calculate_discount(Decimal("150")) assert result == Decimal("15") # 3. Implement def calculate_discount(total: Decimal) -> Decimal: if total > 100: return total * Decimal("0.1") return Decimal("0") ``` ## Layer Boundary Testing Overview Test **what crosses layer boundaries**, not internal implementation: - **Entity Layer**: Domain logic, validation, transformations (from_request, to_response, to_record) - **Service Layer**: Business workflows, error handling, dependency orchestration - **Repository Layer**: CRUD operations, query logic, entity ↔ record transformations - **Router Layer**: Request validation, response serialization, status codes See references/boundaries.md for comprehensive layer-specific examples. ## Entity Testing Example Test transformations and ...

Details

Author
martinffx
Repository
martinffx/atelier
Created
6 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category