MELD
MELD copied to clipboard
feat: Set up comprehensive Python testing infrastructure with Poetry
Set Up Python Testing Infrastructure for MELD
Summary
This PR establishes a comprehensive testing infrastructure for the MELD (Multimodal EmotionLines Dataset) project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Configuration: Added
pyproject.tomlwith Poetry configuration for dependency management - Package Structure: Configured packages to include
baselineandutilsmodules - Development Dependencies: Added pytest (7.4.0+), pytest-cov (4.1.0+), and pytest-mock (3.11.1+) as development dependencies
Testing Infrastructure
- Directory Structure: Created organized test directories:
tests/- Root testing directorytests/unit/- For unit teststests/integration/- For integration tests- All directories include
__init__.pyfiles for proper Python package recognition
Test Configuration
-
pytest Configuration: Comprehensive pytest settings in
pyproject.toml:- Test discovery patterns for flexible naming conventions
- Coverage reporting with HTML and XML output formats
- Strict markers and configuration
- Custom test markers:
unit,integration,slow - Verbose output with clear failure reporting
-
Coverage Configuration:
- Source tracking for
baselineandutilsmodules - Exclusion patterns for test files and common Python artifacts
- HTML coverage reports in
htmlcov/directory - XML coverage report for CI integration
- Coverage threshold set to 0% initially (should be increased as tests are added)
- Source tracking for
Shared Test Fixtures
Created comprehensive fixtures in conftest.py:
temp_dir: Temporary directory for test file operationsmock_config: Configuration dictionary for testingsample_dialogue_data: Sample MELD dialogue structureemotion_labels: List of 7 MELD emotionssentiment_labels: List of 3 MELD sentimentsmock_csv_data: Creates mock CSV files for data loading testsmock_pickle_data: Mock data structure for pickle file testingdata_path: Creates mock data directory structurereset_environment: Ensures clean environment for each testcapture_stdout: Captures print statements for testing
Validation Tests
Created test_setup_validation.py to verify the infrastructure:
- Confirms pytest installation
- Validates project structure
- Tests all fixture availability
- Verifies test markers work correctly
- Ensures coverage reporting is configured
Build Configuration
- Git Ignore: Comprehensive
.gitignorefile including:- Python artifacts (
__pycache__,*.pyc, etc.) - Testing artifacts (
.pytest_cache/,coverage.xml,htmlcov/) - Virtual environments
- IDE files
- Claude-specific directories (
.claude/*) - Build and distribution files
- Python artifacts (
Poetry Scripts
Configured convenient test commands:
poetry run test- Run all tests with coveragepoetry run tests- Alternative command (both work identically)
How to Use
-
Install Dependencies:
poetry install -
Run Tests:
poetry run test # or poetry run tests -
Run Specific Test Types:
# Run only unit tests poetry run pytest -m unit # Run only integration tests poetry run pytest -m integration # Exclude slow tests poetry run pytest -m "not slow" -
View Coverage Reports:
- HTML Report: Open
htmlcov/index.htmlin a browser - Terminal Report: Automatically displayed after test runs
- XML Report: Available at
coverage.xmlfor CI tools
- HTML Report: Open
Notes
- Coverage threshold is currently set to 0% to allow initial setup. This should be increased to 80% (or appropriate level) as actual tests are added
- The infrastructure is ready for immediate test development
- All pytest standard options are available through the Poetry commands
- The validation tests confirm that the setup is working correctly
Next Steps
Developers can now:
- Write unit tests in
tests/unit/ - Write integration tests in
tests/integration/ - Use the provided fixtures for common testing scenarios
- Gradually increase coverage thresholds as tests are added