Skip to content

Conversation

@llbbl
Copy link

@llbbl llbbl commented Sep 3, 2025

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.

- Add Poetry as package manager with pyproject.toml configuration
- Migrate dependencies from requirements.txt to Poetry format
- Add testing dependencies (pytest, pytest-cov, pytest-mock)
- Configure pytest with coverage reporting, custom markers, and strict options
- Create testing directory structure (tests/, unit/, integration/)
- Add comprehensive shared fixtures in conftest.py
- Set up coverage configuration with 80% threshold and HTML/XML reports
- Create validation test suite to verify infrastructure functionality
- Update .gitignore with Claude Code entries
- Support for unit, integration, and slow test markers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant