MGeo
MGeo copied to clipboard
feat: add comprehensive Python testing infrastructure with Poetry
Add Comprehensive Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the geo-multimodal-retrieval project using Poetry as the package manager. The infrastructure provides a robust foundation for writing and running tests across the entire codebase.
Changes Made
Package Management
- Created
pyproject.tomlwith Poetry configuration - Migrated all dependencies from
requirements.txtto Poetry format with compatible versions - Added development dependencies:
pytest,pytest-cov,pytest-mock
Testing Configuration
- Comprehensive pytest configuration in
pyproject.tomlincluding:- Test discovery patterns for files, classes, and functions
- Custom markers:
unit,integration,slow - Coverage settings with 80% threshold
- HTML and XML coverage reports (htmlcov/, coverage.xml)
- Strict configuration and verbose output
Directory Structure
- Created organized test structure:
tests/ ├── __init__.py ├── conftest.py # Shared fixtures ├── test_infrastructure.py # Validation tests ├── unit/ │ └── __init__.py └── integration/ └── __init__.py
Shared Fixtures (conftest.py)
temp_dir- Temporary directory managementmock_config- Mock configuration objectssample_data- Sample datasets for testingmock_model- Mock PyTorch modelsmock_tokenizer- Mock tokenization utilitiessample_tensor- Sample tensor datacleanup_files- File cleanup managementtest_data_dir- Session-scoped test data directorymock_yaml_config- Mock YAML configuration
Scripts and Commands
- Poetry scripts for easy test execution:
poetry run test- Run all testspoetry run tests- Alternative test command
- Standard pytest commands remain available
Additional Setup
- Updated
.gitignorewith testing artifacts and Claude Code settings - Created validation tests to verify infrastructure functionality
- Coverage configuration with source code inclusion and exclusion patterns
Testing Instructions
Install Dependencies
poetry install
Run All Tests
poetry run pytest
# or
poetry run test
# or
poetry run tests
Run Specific Test Categories
poetry run pytest -m unit # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m slow # Slow tests only
Coverage Reports
poetry run pytest --cov-report=html # Generate HTML coverage report
poetry run pytest --cov-report=term # Terminal coverage report
Run Validation Tests
poetry run pytest tests/test_infrastructure.py -v
Infrastructure Validation
All validation tests pass successfully, confirming:
- ✅ Python version compatibility (3.8+)
- ✅ Pytest markers are properly configured
- ✅ Project structure is correctly set up
- ✅ All fixtures are working as expected
- ✅ Test discovery and execution function properly
- ✅ Coverage reporting generates correctly
Next Steps
Developers can now immediately start writing tests:
- Unit tests in
tests/unit/for individual functions/classes - Integration tests in
tests/integration/for component interactions - Use the provided fixtures in
conftest.pyfor common testing scenarios - Follow the established patterns in
test_infrastructure.py
Notes
- Poetry lock file will be generated after successful dependency installation
- Coverage threshold is set to 80% - adjust in
pyproject.tomlif needed - Some dependencies (like PyTorch) may require platform-specific installation
- Testing dependencies are isolated in the
[tool.poetry.group.test.dependencies]section