This document outlines the testing approach for PyMapGIS, designed to balance comprehensive testing with CI/CD reliability.
Location: tests/test_ci_core.py, */test_*_simple.py
Purpose: Essential functionality verification without optional dependencies
Run with: poetry run pytest tests/test_ci_core.py tennessee_counties_qgis/test_tennessee_simple.py examples/arkansas_counties_qgis/test_arkansas_simple.py
What they test:
- Core PyMapGIS imports and basic functionality
- Project structure integrity
- Basic vector operations (with graceful dependency handling)
- Example project structure validation
- Python version compatibility
Location: tests/test_*.py
Purpose: Comprehensive testing including optional dependencies
Run with: poetry run pytest tests/
What they test:
- Advanced raster operations (requires zarr, xarray)
- Streaming functionality (requires kafka-python, paho-mqtt)
- Network analysis (requires osmnx, networkx)
- Visualization (requires pydeck, matplotlib)
- End-to-end integration tests
Location: */test_*_counties.py (standalone scripts)
Purpose: Full example validation with real data
Run with: python arkansas_counties_test.py (individual scripts)
The CI runs only essential tests to avoid dependency hell:
- run: poetry run pytest tests/test_ci_core.py tennessee_counties_qgis/test_tennessee_simple.py examples/arkansas_counties_qgis/test_arkansas_simple.py -v- Reliability: CI tests don't fail due to missing optional dependencies
- Speed: Faster CI runs with focused test scope
- Maintainability: Fewer moving parts in CI environment
- Coverage: Still validates core functionality and project structure
poetry run pytest tests/test_ci_core.py -vpoetry run pytest tests/ -v# Skip slow tests
poetry run pytest -m "not slow"
# Skip tests requiring optional dependencies
poetry run pytest -m "not optional_deps"
# Run only integration tests
poetry run pytest -m "integration"Tests are marked with categories:
@pytest.mark.slow- Long-running tests@pytest.mark.integration- Integration tests@pytest.mark.optional_deps- Requires optional dependencies@pytest.mark.ci_skip- Skip in CI environments
Add to tests/test_ci_core.py or create new test_*_simple.py files.
Requirements:
- No optional dependencies
- Fast execution (< 30 seconds)
- Core functionality only
Add to appropriate tests/test_*.py files.
Requirements:
- Mark with appropriate pytest markers
- Handle missing dependencies gracefully
- Include comprehensive error testing
- Check if new dependencies were added without updating CI strategy
- Verify core tests still pass locally:
poetry run pytest tests/test_ci_core.py - Check for import order issues (E402 linting errors)
- Install optional dependencies:
poetry install --all-extras - Check for missing test data files
- Verify environment-specific configurations
"CI tests should never fail due to missing optional dependencies or complex integrations."
The goal is to have a robust CI pipeline that validates core functionality while allowing comprehensive testing in development environments.