MetaVec icon indicating copy to clipboard operation
MetaVec copied to clipboard

feat: Set up comprehensive Python testing infrastructure

Open llbbl opened this issue 3 months ago • 0 comments

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.toml with full dependency specification
  • Migrated dependencies from environment.yml to 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 directory
    • tests/unit/ - Unit tests
    • tests/integration/ - Integration tests
    • All with proper __init__.py files

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 tests
    • poetry 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.xml for 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

llbbl avatar Sep 02 '25 18:09 llbbl