MMC
MMC 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 MMC Chart Understanding project, providing a ready-to-use testing environment for developers to immediately start writing tests.
Changes Made
Package Management
- Poetry Configuration: Set up Poetry as the primary package manager with
pyproject.toml - Dependencies: Added core dependencies including
numpyfor existing code - Testing Dependencies: Added
pytest,pytest-cov, andpytest-mockin test/dev groups
Testing Configuration
- pytest Settings: Comprehensive pytest configuration with:
- Test discovery patterns (
test_*.py,*_test.py) - Coverage reporting (80% threshold, HTML and XML formats)
- Strict configuration and verbose output
- Custom markers:
unit,integration,slow
- Test discovery patterns (
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── unit/
│ └── __init__.py
├── integration/
│ └── __init__.py
└── test_infrastructure.py # Validation tests
Testing Infrastructure Components
- Shared Fixtures: Comprehensive fixtures in
conftest.pyincluding:temp_dir: Temporary directory managementsample_eval_data: Mock evaluation data for testingmock_file_system: Mock file system structuremock_responses: Sample response data for parser testing- Automatic random seed reset for reproducible tests
Code Fixes
- Missing Functions: Added
save_json()andCAT_SHORT2LONGmapping toutils.py - Import Fixes: Added missing imports (
json,typing.Dict) - Package Structure: Created
Eval/__init__.pyto make it a proper Python package
Development Tools
- Coverage Reporting: HTML reports in
htmlcov/, XML reports incoverage.xml - Gitignore: Updated with testing-related entries and Claude settings
- Validation: Infrastructure validation tests ensure everything works correctly
Testing Instructions
Running Tests
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=Eval --cov-report=html
# Run specific markers
poetry run pytest -m unit # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m slow # Slow tests only
# Run specific directories
poetry run pytest tests/unit/ # Unit tests directory
poetry run pytest tests/integration/ # Integration tests directory
Coverage Reports
- Terminal: Coverage summary displayed after test runs
- HTML: Detailed reports in
htmlcov/index.html - XML: Machine-readable reports in
coverage.xml
Validation Results
✅ All 14 infrastructure validation tests pass
✅ Coverage reporting generates HTML and XML reports
✅ Custom pytest markers work correctly
✅ All fixtures are functional
✅ Project structure validated
✅ Module imports work correctly
Dependencies
The testing infrastructure adds these development dependencies:
pytest ^7.4.0- Main testing frameworkpytest-cov ^4.1.0- Coverage reportingpytest-mock ^3.11.0- Mocking utilities
Next Steps
Developers can now:
- Write unit tests in
tests/unit/directory - Write integration tests in
tests/integration/directory - Use provided fixtures from
conftest.py - Run
poetry installto set up the environment - Start testing immediately with
poetry run pytest
The infrastructure is ready for immediate use with comprehensive coverage reporting and proper test organization.
🤖 Generated with Claude Code