Add comprehensive testing infrastructure with Poetry and pytest #254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About UnitSeeker
Hi! This PR is part of the UnitSeeker project, a human-guided initiative to help Python repositories establish testing infrastructure.
Key points:
Learn more about the project and see the stats on our progress at https://unitseeker.llbbl.com/
Summary
This PR adds a complete testing infrastructure to the audio-webui project, providing a solid foundation for writing and running tests. The setup uses Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
pyproject.tomlwith Poetry configurationTesting Dependencies
Testing Configuration
✅ Comprehensive pytest configuration in
pyproject.toml:unit,integration,slow✅ Coverage configuration:
Directory Structure
Shared Fixtures (
conftest.py)Created comprehensive test fixtures including:
temp_dir/temp_file- Temporary filesystem resourcesmock_config- Mock configuration dictionariesmock_env_vars- Environment variable mockingmock_torch/mock_gradio/mock_huggingface_model- ML framework mockssample_audio_path/sample_model_config- Test data helpersmock_file_system- Mock directory structureproject_root- Project path helperreset_environment- Auto-reset environment stateValidation Tests
Development Scripts
Added convenient Poetry scripts:
Both commands support all standard pytest options:
Updated .gitignore
Added entries for:
.pytest_cache/,.coverage,htmlcov/,coverage.xml).claude/*)build/,dist/,*.egg-info/)Note:
poetry.lockis intentionally tracked in version control.Running Tests
First Time Setup
Running Tests
Coverage Reports
After running tests with coverage, reports are generated in:
htmlcov/index.html(open in browser)coverage.xml(for CI/CD integration)Validation
All validation tests pass successfully:
Notes
Coverage Threshold
The current configuration requires 80% test coverage. Since this PR only adds infrastructure without actual unit tests, the coverage threshold will fail until tests are written. To run tests without failing on coverage:
poetry run test --no-covOr temporarily, you can adjust the threshold in
pyproject.toml:Python Version
The project is configured for Python 3.10+. The original readme mentioned 3.10 specifically due to TTS library compatibility, but the Poetry config allows newer versions. Adjust if needed:
Next Steps
This PR provides the foundation. Suggested next steps:
Testing Philosophy
The infrastructure is set up with best practices:
Questions or concerns? Feel free to comment, request changes, or close this PR if it doesn't fit your needs. I'm happy to make adjustments based on your feedback!