QualiCLIP
QualiCLIP copied to clipboard
feat: add comprehensive Python testing infrastructure
Add Comprehensive Python Testing Infrastructure
Summary
This PR sets up a complete testing infrastructure for the QualiCLIP project, providing developers with a ready-to-use testing environment.
Changes Made
- Package Management: Migrated from shell script dependencies to Poetry-managed dependencies in
pyproject.toml - Testing Framework: Configured pytest with comprehensive settings including coverage reporting, custom markers, and strict options
- Project Structure: Created proper testing directory structure with
tests/unit/andtests/integration/subdirectories - Coverage Configuration: Set up coverage reporting with HTML/XML output, 80% threshold, and appropriate exclusions
- Shared Fixtures: Created comprehensive
conftest.pywith common testing fixtures for images, tensors, devices, and configurations - Git Integration: Updated
.gitignorewith testing-related entries and build artifacts - Validation: Added validation tests to verify the testing infrastructure works correctly
Testing Infrastructure Components
Dependencies
pytest- Main testing frameworkpytest-cov- Coverage reportingpytest-mock- Mocking utilities
Configuration Features
- Test Discovery: Automatic discovery of test files and functions
- Coverage: 80% coverage threshold with HTML and XML reports
- Custom Markers:
@pytest.mark.unit,@pytest.mark.integration,@pytest.mark.slow - Strict Mode: Strict marker and config validation
- Filtering: Warning filters for cleaner output
Shared Fixtures
temp_dir- Temporary directory for testingsample_image- RGB test imagessample_tensor- Normalized tensorsdevice- CUDA/CPU device detectionmock_model_config- Mock model configurationsmock_transforms- Image transformation pipelines
Instructions for Running Tests
# Install dependencies
poetry install
# Run all tests
poetry run pytest
# Run tests with coverage
poetry run pytest --cov=clip --cov-report=html
# Run only unit tests
poetry run pytest -m unit
# Run only integration tests
poetry run pytest -m integration
# Skip slow tests
poetry run pytest -m "not slow"
# Run validation tests to verify setup
poetry run pytest tests/test_setup_validation.py -v
Development Notes
- All original dependencies from
install_requirements.shhave been preserved inpyproject.toml - Poetry lock file is included in version control for reproducible builds
- Coverage reports are generated in
htmlcov/directory - Test markers allow for selective test execution
- Validation tests ensure the infrastructure works correctly
🤖 Generated with Claude Code