DiverseEvol
DiverseEvol 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 diverse-evol project, providing developers with a ready-to-use testing environment. The setup migrates the project from Conda-only dependency management to Poetry while maintaining all existing dependencies.
Changes Made
Package Management
- ✅ Poetry Setup: Created
pyproject.tomlwith complete Poetry configuration - ✅ Dependency Migration: Migrated all dependencies from
environment.ymlto Poetry format - ✅ Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies
Testing Configuration
- ✅ pytest Configuration: Comprehensive pytest settings in
pyproject.tomlincluding:- 80% test coverage threshold with HTML/XML reporting
- Custom markers:
unit,integration,slow - Strict configuration with proper test discovery patterns
- Coverage exclusions for test files and common directories
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures and test configuration
├── unit/ # Unit tests
│ └── __init__.py
├── integration/ # Integration tests
│ └── __init__.py
└── test_setup_validation.py # Infrastructure validation tests
Testing Features
-
✅ Shared Fixtures: Comprehensive fixture library in
conftest.pyincluding:- Temporary directories and file management
- Mock configurations for models, tokenizers, and APIs
- Sample data fixtures (Alpaca format, test data, metrics)
- Environment management and GPU mocking
- Random seed reset for reproducible tests
-
✅ Validation Tests: Complete test suite to verify infrastructure works correctly
-
✅ Poetry Scripts: Easy-to-use commands (
poetry run testandpoetry run tests)
Development Environment
- ✅ Updated .gitignore: Added comprehensive patterns for:
- Testing artifacts (
.pytest_cache/,htmlcov/,coverage.xml) - Virtual environments and build artifacts
- IDE files and OS-specific files
- Claude Code settings
- Testing artifacts (
How to Use
Running Tests
# Run all tests
poetry run test
# Run specific test categories
poetry run pytest -m unit # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m "not slow" # Skip slow tests
# Run with coverage report
poetry run pytest --cov
# Run specific test files
poetry run pytest tests/test_setup_validation.py -v
Writing Tests
- Unit tests: Place in
tests/unit/ - Integration tests: Place in
tests/integration/ - Use fixtures: Leverage the comprehensive fixture library in
conftest.py - Mark tests: Use
@pytest.mark.unit,@pytest.mark.integration, or@pytest.mark.slow
Validation Results
The testing infrastructure has been validated with:
- ✅ Basic pytest functionality working
- ✅ Project structure validation
- ✅ Custom markers and fixtures functional
- ✅ Poetry commands (
poetry run test) working correctly - ✅ Coverage reporting configured properly
Notes
- The existing
environment.ymlis preserved for backwards compatibility - All original dependencies are maintained in Poetry format
- Testing dependencies are properly isolated as development dependencies
- The setup is ready for immediate use - developers can start writing tests right away
Dependencies Added
pytest ^7.4.0- Main testing frameworkpytest-cov ^4.1.0- Coverage reportingpytest-mock ^3.11.1- Mocking utilities
🤖 Generated with Claude Code