MetaVec
MetaVec copied to clipboard
feat: Set up comprehensive Python testing infrastructure
Set Up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the MetaVec project, migrating from conda-based dependency management to Poetry and setting up a complete testing framework.
Changes Made
Package Management
- Added Poetry configuration in
pyproject.tomlwith full dependency specification - Migrated dependencies from
environment.ymlto Poetry format with Python 3.11 compatibility - Updated Python versions and package versions to work with current environment
Testing Framework
- Configured pytest with comprehensive settings including:
- Coverage reporting (80% threshold)
- HTML and XML coverage reports
- Custom test markers (
unit,integration,slow) - Strict configuration and test discovery patterns
Directory Structure
- Created testing directories:
tests/- Root testing directorytests/unit/- Unit teststests/integration/- Integration tests- All with proper
__init__.pyfiles
Testing Utilities
- Comprehensive fixtures in
tests/conftest.py:- Temporary directories for file-based tests
- Sample embeddings and vocabulary for ML testing
- Mock configurations and PyTorch device setup
- Environment cleanup and seeding utilities
Development Workflow
- Poetry scripts for running tests:
poetry run test- Run all testspoetry run tests- Alternative command
- Validation tests to verify infrastructure works correctly
- Updated .gitignore with testing artifacts and IDE files
Testing Instructions
Installation
poetry install
Running Tests
# Run all tests
poetry run test
# Run with verbose output
poetry run pytest -v
# Run only unit tests
poetry run pytest -m unit
# Run with coverage report
poetry run pytest --cov=MetaVec --cov-report=html
Coverage Reports
- Terminal: Displays missing coverage after test runs
- HTML: Generated in
htmlcov/directory - XML: Generated as
coverage.xmlfor CI integration
Notes
- Dependencies updated to Python 3.11 compatible versions
- Poetry lock file preserved in version control for reproducible builds
- No actual unit tests added - only testing infrastructure and validation
- Ready for development - developers can immediately start writing tests using the established patterns
Validation
All validation tests pass successfully:
- ✅ Basic pytest functionality
- ✅ NumPy and scientific computing stack
- ✅ Fixture system working correctly
- ✅ Test markers and categorization
- ✅ Temporary file handling
- ✅ Coverage reporting integration