Skip to content

feat: Set up comprehensive Python testing infrastructure#2

Open
llbbl wants to merge 1 commit intoikergarcia1996:mainfrom
UnitSeeker:add-testing-infrastructure
Open

feat: Set up comprehensive Python testing infrastructure#2
llbbl wants to merge 1 commit intoikergarcia1996:mainfrom
UnitSeeker:add-testing-infrastructure

Conversation

@llbbl
Copy link
Copy Markdown

@llbbl llbbl commented Sep 2, 2025

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

- Add Poetry package manager with pyproject.toml configuration
- Migrate dependencies from environment.yml to Poetry format
- Configure pytest with coverage reporting and custom markers
- Set up testing directory structure (tests/, unit/, integration/)
- Create shared fixtures in conftest.py for common test utilities
- Add development scripts for running tests (poetry run test/tests)
- Update .gitignore with testing and IDE-related entries
- Include validation tests to verify infrastructure setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant