Depyler TDD Book¶
Welcome to the Depyler TDD Book - a comprehensive, test-driven reference for Python's standard library, designed to validate the Depyler transpiler.
π― Overview¶
This project provides extensively tested examples of Python's standard library. Each module is:
- β Verified: All code is tested with pytest (1350+ tests)
- π Quality-Controlled: PMAT quality gates enforce A+ code standards
- π Edge-Case Focused: Property-based testing with Hypothesis
- π Documentation-Ready: Tests generate reference documentation
- π Mutation Tested: Ensures test quality through mutation testing
π Current Status¶
Integration Progress
- Modules Covered: 27/200 (13.5%)
- Test Pass Rate: 1350/1350 (100%)
- Coverage: 99.8%
- SATD: 0 (zero technical debt)
See the Integration Status page for detailed progress tracking.
π Quick Start¶
Running Tests Locally¶
# Install dependencies
cd tdd-book
pip install -r requirements.txt
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov --cov-report=html
# Run specific module
pytest tests/test_json/ -v
Quality Gates¶
# Run quality checks (requires pmat)
pmat analyze complexity --fail-on-violation
pmat analyze satd --fail-on-violation
pmat quality-gate --strict
π Module Documentation¶
Explore comprehensive test-driven documentation for Python standard library modules:
Phase 1: Core Utilities β Complete¶
- os - Operating system interfaces
- sys - System-specific parameters
- pathlib - Object-oriented filesystem paths
- time - Time access and conversions
- datetime - Date and time handling
- calendar - Calendar operations
Phase 2: Data Processing β Complete¶
- json - JSON encoding and decoding
- csv - CSV file reading and writing
- collections - Container datatypes
- itertools - Iterator building blocks
- functools - Higher-order functions
- copy - Shallow and deep copy operations
- array - Efficient arrays
- base64 - Base64 encoding
- decimal - Decimal arithmetic
- fractions - Rational numbers
- hashlib - Secure hashes
- io - Core I/O tools
- math - Mathematical functions
- random - Random number generation
π― Quality Standards¶
All code in this book adheres to strict quality standards:
| Metric | Target | Current |
|---|---|---|
| Cyclomatic Complexity | β€10 per function | β Passing |
| Test Coverage | β₯80% | β 99.8% |
| SATD Count | 0 | β 0 |
| Type Coverage | 100% for public APIs | β Passing |
π Edge Cases¶
Discover interesting edge cases and stdlib behaviors:
π οΈ Development Workflow¶
TDD Protocol¶
- Write Test First: Create failing test
- Run Test: Verify it fails
- Implement: Make test pass
- Refactor: Improve code quality
- Quality Check: Run quality gates
Example¶
# tests/test_example/test_feature.py
def test_json_encode_unicode():
"""JSON should properly encode Unicode characters."""
data = {"message": "Hello δΈη"}
result = json.dumps(data, ensure_ascii=False)
assert result == '{"message": "Hello δΈη"}'
π Project Goals¶
- Transpiler Validation: Provide reference implementations for Depyler
- Edge Case Discovery: Find and document stdlib corner cases
- Quality Assurance: Demonstrate A+ code standards
- Educational Resource: Teach TDD and Python stdlib
π€ Contributing¶
Contributions are welcome! Please:
- Follow the TDD protocol
- Ensure all quality gates pass
- Add comprehensive edge case tests
- Document any stdlib bugs discovered
π License¶
MIT License - See the main repository for details.