SciGLM icon indicating copy to clipboard operation
SciGLM copied to clipboard

feat: Set up comprehensive Python testing infrastructure

Open llbbl opened this issue 3 months ago โ€ข 0 comments

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.toml including 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 setup
  • tests/ directory structure with proper __init__.py files
  • tests/conftest.py - Comprehensive shared fixtures for common testing scenarios
  • tests/test_infrastructure.py - Validation test suite to verify setup functionality
  • .gitignore - Updated with Claude Code entries

๐Ÿงช Testing Features

  • Custom Test Markers: unit, integration, and slow markers 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 components
  • tests/integration/ - Integration tests for component interactions
  • tests/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_*.py and *_test.py files
  • 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.txt dependencies have been migrated to Poetry format
  • Poetry lock file is intentionally not in .gitignore for reproducible builds
  • Infrastructure is ready for immediate use - no additional setup required
  • Comprehensive fixtures in conftest.py provide common testing utilities

This setup provides a solid foundation for test-driven development and ensures code quality through automated testing and coverage reporting.

llbbl avatar Sep 03 '25 22:09 llbbl