Skip to content

Conversation

llbbl
Copy link

@llbbl llbbl commented Sep 4, 2025

Set up Python Testing Infrastructure

Summary

This PR establishes a complete testing infrastructure for the geospatial tile processing project, providing developers with all necessary tools and configurations to write and run comprehensive tests.

Changes Made

Package Management

  • Set up Poetry as the primary package manager with pyproject.toml
  • Migrated dependencies from requirements.txt to Poetry configuration
  • Updated versions of key dependencies (Shapely, pyclipper, requests) to resolve compatibility issues

Testing Framework

  • Added pytest as the main testing framework
  • Configured pytest-cov for coverage reporting with 80% threshold
  • Added pytest-mock for comprehensive mocking capabilities
  • Set up test discovery patterns for automatic test collection

Directory Structure

tests/
├── __init__.py
├── conftest.py              # Shared fixtures and test utilities
├── unit/__init__.py         # Unit tests directory
├── integration/__init__.py  # Integration tests directory
└── test_setup_validation.py # Validation tests

Configuration Features

  • Coverage reporting in HTML, XML, and terminal formats
  • Test markers for categorizing tests (unit, integration, slow)
  • Comprehensive fixtures in conftest.py including:
    • Temporary directory management
    • Sample GeoJSON data fixtures
    • Mock HTTP responses
    • Environment variable mocking
    • File creation utilities

Quality Assurance

  • Coverage thresholds enforced at 80%
  • Strict pytest configuration with warnings as errors
  • Source code coverage excluding test files and virtual environments
  • HTML coverage reports generated in htmlcov/ directory

Running Tests

After this PR is merged, developers can run tests using:

# Install dependencies
poetry install

# Run all tests
poetry run pytest

# Run tests with verbose output
poetry run pytest -v

# Run only unit tests
poetry run pytest -m unit

# Run tests excluding slow ones
poetry run pytest -m "not slow"

# Generate coverage report
poetry run pytest --cov-report=html

Test Coverage

The setup includes comprehensive coverage reporting that:

  • Tracks code coverage across the entire project
  • Generates HTML reports for detailed analysis
  • Exports XML for CI/CD integration
  • Shows missing line numbers for uncovered code

Next Steps

With this infrastructure in place, developers can now:

  1. Write unit tests for individual functions (parser.py, scraper.py)
  2. Create integration tests for end-to-end workflows
  3. Add performance tests using the slow marker
  4. Extend fixtures in conftest.py as needed

The validation tests confirm that all components are working correctly and the project modules can be imported and tested successfully.

- Configure Poetry as package manager with pyproject.toml
- Add pytest, pytest-cov, and pytest-mock testing dependencies
- Create tests/ directory structure with unit/ and integration/ subdirectories
- Configure pytest with coverage reporting (80% threshold, HTML/XML output)
- Add test markers for unit, integration, and slow tests
- Create shared fixtures in conftest.py for common testing utilities
- Update .gitignore with Claude Code settings
- Add validation tests to verify infrastructure setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant