PDVC
PDVC copied to clipboard
feat: Add comprehensive Python testing infrastructure with Poetry
Add Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the PDVC (Parallel Decoding for Video Captioning) project. It introduces Poetry as the package manager, sets up pytest with coverage reporting, and creates a foundation for writing unit and integration tests.
Changes Made
Package Management
- Poetry Setup: Created
pyproject.tomlwith Poetry configuration - Dependency Migration: Migrated all dependencies from
requirement.txtto Poetry - Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies
Testing Configuration
- pytest Configuration:
- Configured test discovery patterns
- Set up coverage reporting with 80% threshold
- Added custom test markers:
unit,integration, andslow - Configured HTML and XML coverage reports
- Coverage Settings:
- Included all main source directories
- Excluded test files and CUDA operation sources from coverage
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_setup_validation.py # Infrastructure validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Test Fixtures
Created comprehensive fixtures in conftest.py:
temp_dir: Temporary directory managementmock_config: Configuration mockingsample_video_features: Test data for video featuressample_captions: Test data for captionsmock_model: PyTorch model mockingmock_dataloader: DataLoader mockingsample_yaml_config: YAML configuration testingmock_h5_file: HDF5 file mockingdevice: CUDA/CPU device selectionreset_random_seeds: Reproducibility fixture
Additional Updates
- Updated
.gitignoreto exclude testing artifacts and poetry.lock - Created validation tests to ensure infrastructure works correctly
Running Tests
Using Poetry Commands
# Install dependencies
poetry install
# Run all tests
poetry run test
# or
poetry run tests
# Run with specific markers
poetry run pytest -m unit
poetry run pytest -m integration
poetry run pytest -m "not slow"
# Run with coverage report
poetry run pytest --cov-report=html
Direct pytest Usage
# After activating the virtual environment
pytest
pytest -v # Verbose output
pytest tests/unit/ # Run only unit tests
Notes
- The coverage threshold is set to 80% but currently the project has 0% coverage as no actual unit tests have been written yet
- The testing infrastructure is ready for developers to start writing tests immediately
- All test dependencies are isolated in the development dependency group
- The validation tests confirm that all components are properly installed and configured
Next Steps
- Write unit tests for core modules (pdvc, video_backbone, data)
- Add integration tests for the full pipeline
- Set up continuous integration to run tests automatically
- Consider adding additional testing tools (e.g., hypothesis for property-based testing)