bark-ml
bark-ml copied to clipboard
feat: set up comprehensive Python testing infrastructure
Set up comprehensive Python testing infrastructure
Summary
This PR establishes a complete testing infrastructure for the BARK-ML project, providing developers with all the tools needed to write and run tests effectively.
Changes Made
- Package Management: Set up Poetry as the package manager with
pyproject.tomlconfiguration - Testing Framework: Configured pytest with comprehensive settings including:
- Coverage reporting with 80% threshold
- Custom markers for organizing tests (
unit,integration,slow) - Strict configuration for better test reliability
- HTML and XML coverage reports
- Directory Structure: Created organized test structure:
tests/- Root test directorytests/unit/- Unit test subdirectorytests/integration/- Integration test subdirectory- All directories include proper
__init__.pyfiles
- Shared Fixtures: Added
tests/conftest.pywith comprehensive fixtures:- Temporary file and directory management
- Mock objects for environments, agents, and models
- Sample configurations and data structures
- Environment cleanup utilities
- Development Dependencies: Added essential testing packages:
pytest- Main testing frameworkpytest-cov- Coverage reportingpytest-mock- Enhanced mocking utilities
- Configuration: Updated
.gitignorewith testing artifacts and development files - Validation: Created validation tests to verify infrastructure works correctly
Running Tests
After this PR is merged, developers can run tests using:
# Install dependencies
poetry install
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=bark_ml
# Run specific test types
poetry run pytest -m unit # Only unit tests
poetry run pytest -m integration # Only integration tests
poetry run pytest -m slow # Only slow tests
# Run tests in specific directories
poetry run pytest tests/unit/
poetry run pytest tests/integration/
Coverage Reports
The testing infrastructure generates coverage reports in multiple formats:
- Terminal output with missing line numbers
- HTML report in
htmlcov/directory - XML report as
coverage.xmlfor CI integration
Test Organization
Tests are organized using pytest markers:
@pytest.mark.unit- Fast, isolated unit tests@pytest.mark.integration- Tests that check component interactions@pytest.mark.slow- Long-running tests (can be excluded in CI)
Development Notes
- The
poetry.lockfile is NOT added to.gitignoreas it should be committed for reproducible builds - Coverage threshold is set to 80% but can be adjusted in
pyproject.toml - All major Python versions (3.7+) are supported
- Comprehensive fixtures are available in
conftest.pyfor common testing scenarios
Testing the Infrastructure
The PR includes validation tests that verify:
- All testing tools are properly installed and configured
- Fixtures are working correctly
- Test discovery and execution work as expected
- Coverage reporting generates properly
🤖 Generated with Claude Code