Skip to content

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

  1. Write Test First: Create failing test
  2. Run Test: Verify it fails
  3. Implement: Make test pass
  4. Refactor: Improve code quality
  5. 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

  1. Transpiler Validation: Provide reference implementations for Depyler
  2. Edge Case Discovery: Find and document stdlib corner cases
  3. Quality Assurance: Demonstrate A+ code standards
  4. Educational Resource: Teach TDD and Python stdlib

🀝 Contributing

Contributions are welcome! Please:

  1. Follow the TDD protocol
  2. Ensure all quality gates pass
  3. Add comprehensive edge case tests
  4. Document any stdlib bugs discovered

πŸ“„ License

MIT License - See the main repository for details.

πŸ”— Resources