SpecAugment
SpecAugment copied to clipboard
feat: Add comprehensive Python testing infrastructure with Poetry
Add Comprehensive Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the SpecAugment project using Poetry as the package manager and pytest as the testing framework.
Changes Made
- Package Management: Set up Poetry configuration in
pyproject.tomlwith all existing dependencies (numpy, tensorflow, librosa, matplotlib) - Testing Framework: Configured pytest with comprehensive settings including:
- Test discovery patterns
- Coverage reporting (80% threshold)
- Custom markers for unit, integration, and slow tests
- HTML and XML coverage reports
- Testing Dependencies: Added development dependencies:
pytest(main testing framework)pytest-cov(coverage reporting)pytest-mock(mocking utilities)
- Directory Structure: Created organized test directories:
tests/(root test directory)tests/unit/(unit tests)tests/integration/(integration tests)tests/conftest.py(shared fixtures)
- Shared Fixtures: Comprehensive fixtures in
conftest.pyincluding:- Sample mel spectrograms and audio data
- Temporary directories for testing
- Mock configurations and parameters
- Random seed management for reproducible tests
- Validation Tests: Added
test_setup_validation.pyto verify infrastructure works correctly - Configuration: Updated
.gitignorewith testing-related entries and Claude settings
Running Tests
# Install dependencies
poetry install
# Run all tests with coverage
poetry run pytest
# Run specific test categories
poetry run pytest -m unit
poetry run pytest -m integration
# Run with verbose output
poetry run pytest -v
# Generate coverage report
poetry run pytest --cov-report=html
Coverage Configuration
- Threshold: 80% minimum coverage required
- Reports: HTML (
htmlcov/), XML (coverage.xml), and terminal output - Exclusions: Properly configured to exclude test files, demo code, and virtual environments
Notes
- Poetry is now the primary package manager for dependency management
- All existing functionality remains unchanged - only testing infrastructure added
- The
tensorflow-addonsdependency has a known compatibility issue on some platforms but doesn't affect core functionality - Ready-to-use environment for developers to immediately start writing tests
Testing Infrastructure Validation
The setup includes comprehensive validation tests that verify:
- All dependencies are properly installed and importable
- Custom fixtures work correctly
- Coverage configuration is proper
- Project structure is as expected
- pytest markers function correctly
This infrastructure provides a solid foundation for maintaining code quality and enabling confident refactoring and feature development.