Skip to content

Build Backend Testing Summary

Overview

This document summarizes the comprehensive testing framework added to ensure all build backends (setuptools, hatchling, flit, pdm) work correctly with the cookiecutter template.

Test Coverage

Core Functionality Tests (TestBuildBackends)

  1. test_backend_pyproject_toml_generation
  2. Verifies that pyproject.toml is correctly generated for each backend
  3. Checks for backend-specific configurations and required fields
  4. Validates build system requirements and build-backend specifications

  5. test_backend_project_structure

  6. Ensures the project structure is correct for all backends
  7. Verifies presence of essential files (src/, tests/, pyproject.toml, etc.)
  8. Checks for backend-specific files like MANIFEST.in for setuptools

  9. test_backend_package_installable

  10. Tests that generated packages can be installed with pip install -e .
  11. Verifies that the package can be imported after installation
  12. Ensures build system works correctly for development installs

  13. test_backend_build_wheel

  14. Tests that wheel files can be built using python -m build
  15. Validates wheel naming conventions and structure
  16. Ensures all backends can produce distributable packages

  17. test_backend_metadata_consistency

  18. Verifies that package metadata is consistent across all backends
  19. Checks that project name, version, description, and Python requirements are preserved
  20. Ensures metadata transformations work correctly

Integration Tests (TestBuildBackendIntegration)

  1. test_backend_with_cli_integration
  2. Tests CLI framework integration (Typer, Click, Argparse) with all backends
  3. Verifies console script entry points are properly configured
  4. Ensures CLI dependencies are correctly added to pyproject.toml

  5. test_backend_with_testing_tools

  6. Tests testing framework integration (pytest, coverage, tox) with all backends
  7. Verifies test dependencies and configuration files are created
  8. Ensures testing workflows work with each build system

  9. test_backend_with_documentation

  10. Tests documentation framework integration (MkDocs, Sphinx) with all backends
  11. Verifies documentation files and configuration are created
  12. Ensures doc dependencies work with each build system

  13. test_backend_performance_comparison

  14. Basic performance testing to ensure all backends complete generation reasonably quickly
  15. Helps identify any performance issues with specific backends

Backend-Specific Tests

  1. test_setuptools_with_cli - Tests setuptools with CLI interfaces
  2. test_hatchling_with_features - Tests hatchling with additional features
  3. test_flit_module_configuration - Tests flit module configuration
  4. test_pdm_backend_configuration - Tests PDM backend configuration
  5. test_all_backends_default_values - Tests all backends with default cookiecutter values

Test Infrastructure

Fixtures and Helpers

  • create_backend_context(): Creates test contexts for specific backends
  • Template directory fixture: Provides access to the cookiecutter template
  • Temporary directory management: Ensures clean test isolation

Test Execution

Tests use pytest with parametrization to run the same test logic across all four backends: - setuptools - hatchling - flit - pdm

Validation Points

Each test validates:

  1. File Generation: Correct files are created for each backend
  2. Configuration: Backend-specific configuration is properly applied
  3. Dependencies: Required build dependencies are included
  4. Functionality: Generated packages actually work (install, import, build)
  5. Integration: Backends work with other template features
  6. Metadata: Package metadata is preserved and correct

Benefits

This comprehensive testing ensures:

  • ✅ All backends generate working Python packages
  • ✅ Backend-specific features are properly configured
  • ✅ Integration with other template features works correctly
  • ✅ Generated packages can be built, installed, and distributed
  • ✅ Metadata consistency across all backends
  • ✅ No regressions when adding new features or backends

Running the Tests

# Run all build backend tests
pytest tests/test_build_backends.py -v

# Run tests for a specific backend
pytest tests/test_build_backends.py -k "setuptools" -v

# Run only core functionality tests
pytest tests/test_build_backends.py::TestBuildBackends -v

# Run only integration tests
pytest tests/test_build_backends.py::TestBuildBackendIntegration -v

Future Enhancements

Potential areas for expansion:

  1. Performance benchmarking between backends
  2. Complex dependency scenarios testing
  3. Multi-platform testing (Windows/Linux/macOS)
  4. Version constraint testing for build dependencies
  5. Custom build configuration testing