SciGLM
SciGLM 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 SciGLM project, providing a robust foundation for test-driven development and quality assurance.
๐ง Infrastructure Components Added
- Poetry Package Manager: Configured with
pyproject.tomlincluding proper Python version constraints for Streamlit compatibility - Testing Framework: pytest with comprehensive configuration including coverage, markers, and strict options
- Coverage Reporting: 80% coverage threshold with HTML and XML report generation
- Testing Dependencies: pytest, pytest-cov, pytest-mock added to development group
- Directory Structure: Organized testing hierarchy with unit and integration test separation
๐ Files Created/Modified
pyproject.toml- New Poetry configuration with dependencies and testing setuptests/directory structure with proper__init__.pyfilestests/conftest.py- Comprehensive shared fixtures for common testing scenariostests/test_infrastructure.py- Validation test suite to verify setup functionality.gitignore- Updated with Claude Code entries
๐งช Testing Features
- Custom Test Markers:
unit,integration, andslowmarkers for selective test execution - Shared Fixtures: Common testing utilities including temp directories, mock configurations, sample data
- Coverage Configuration: Source tracking with appropriate exclusions and detailed reporting
- Environment Management: Automatic cleanup and warning suppression for cleaner test output
๐ Usage Instructions
Running Tests
# Install dependencies
poetry install
# Run all tests
poetry run pytest
# Run specific test types
poetry run pytest -m unit # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m "not slow" # Exclude slow tests
# Run with verbose output
poetry run pytest -v
# Generate coverage reports
poetry run pytest --cov-report=html
Test Organization
tests/unit/- Unit tests for individual componentstests/integration/- Integration tests for component interactionstests/conftest.py- Shared fixtures and configuration- Mark tests with
@pytest.mark.unit,@pytest.mark.integration, or@pytest.mark.slow
๐ Configuration Details
- Python Version: Configured for
>=3.9,<3.9.7 || >3.9.7,<4.0(Streamlit compatibility) - Coverage Threshold: 80% minimum coverage required
- Test Discovery: Automatic discovery of
test_*.pyand*_test.pyfiles - Reporting: Terminal, HTML (
htmlcov/), and XML (coverage.xml) formats
โ Validation
The infrastructure has been validated with:
- 13 passing infrastructure tests covering all major components
- Successful dependency installation and resolution
- Working test markers and fixture system
- Coverage reporting functionality
- Environment cleanup and isolation
๐ Notes
- The existing
requirements.txtdependencies have been migrated to Poetry format - Poetry lock file is intentionally not in
.gitignorefor reproducible builds - Infrastructure is ready for immediate use - no additional setup required
- Comprehensive fixtures in
conftest.pyprovide common testing utilities
This setup provides a solid foundation for test-driven development and ensures code quality through automated testing and coverage reporting.