WLASL
WLASL copied to clipboard
feat: Set up comprehensive Python testing infrastructure with Poetry
Set up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the WLASL Python project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Setup: Initialized Poetry as the package manager with
pyproject.toml - Dependencies: Added testing dependencies as development dependencies:
pytest ^7.4.0- Core testing frameworkpytest-cov ^4.1.0- Coverage reportingpytest-mock ^3.11.1- Mocking utilities
Testing Configuration
-
pytest Configuration: Configured in
pyproject.tomlwith:- Test discovery patterns for flexible test file naming
- Coverage settings with 80% threshold requirement
- HTML and XML coverage report generation
- Strict markers and configuration
- Custom markers:
unit,integration,slow
-
Coverage Configuration: Set up with:
- Source directory tracking (
code/) - Exclusion patterns for test files and virtual environments
- Branch coverage enabled
- Multiple report formats
- Source directory tracking (
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_infrastructure_validation.py # Setup validation
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Testing Fixtures
Created comprehensive shared fixtures in conftest.py:
temp_dir- Temporary directory with automatic cleanupmock_config- Mock configuration objectsample_json_data- Sample JSON test datamock_video_file- Mock video file creationmock_dataset_dir- Complete mock dataset structuremock_model- Mock ML model objectmock_data_loader- Mock data loaderenv_setup- Environment variable setupcapture_logs- Log capture during testscleanup_test_files- Automatic test file cleanupmock_ini_config- Mock INI configuration files
Development Experience
- Commands: Both
poetry run testandpoetry run testswork - Validation: Created validation tests to verify the infrastructure
- Git Integration: Updated
.gitignorewith comprehensive patterns
How to Use
-
Install dependencies:
poetry install --with test -
Run all tests:
poetry run test # or poetry run tests -
Run specific test categories:
# Unit tests only poetry run pytest -m unit # Integration tests only poetry run pytest -m integration # Exclude slow tests poetry run pytest -m "not slow" -
Run with coverage:
poetry run pytest --cov -
Generate coverage reports:
- HTML report:
htmlcov/index.html - XML report:
coverage.xml
- HTML report:
Notes
- The infrastructure is ready for immediate test development
- Coverage threshold is set to 80% but will initially fail since there's no source code to cover
- All validation tests pass, confirming the setup is working correctly
- Poetry.lock file is not gitignored to ensure reproducible builds