GraphLoG
GraphLoG copied to clipboard
feat: Set up comprehensive Python testing infrastructure
Set up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the GraphLoG project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for developers to write and run unit tests, integration tests, and generate coverage reports.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith Poetry setup for dependency management - Dependencies: Added core dependencies (torch, numpy, scikit-learn, pandas, tqdm, tensorboardx)
- Dev Dependencies: Added pytest, pytest-cov, and pytest-mock for comprehensive testing
Testing Framework
- pytest Configuration: Configured with custom markers (
unit,integration,slow) - Coverage Reporting: Set up with 80% coverage threshold, HTML and XML report generation
- Test Discovery: Configured for
test_*.pyand*_test.pypatterns
Directory Structure
- Testing Directories: Created
tests/,tests/unit/, andtests/integration/with proper__init__.pyfiles - Shared Fixtures: Comprehensive
conftest.pywith fixtures for temp directories, mock data, graph structures, and configuration
Additional Setup
- Validation Tests: Created
test_infrastructure.pyto verify the testing setup works correctly - .gitignore: Updated with testing-related entries, coverage files, and development artifacts
- Coverage Configuration: Proper exclusions for test files, virtual environments, and build artifacts
Testing Infrastructure Components
Available Fixtures in conftest.py
temp_dir,temp_file: Temporary filesystem utilitiesmock_config,mock_args: Configuration and argument mockingsample_tensor,sample_graph_data: Test data generationset_seed: Reproducible random number generationcleanup_cuda: CUDA memory management
Custom Markers
@pytest.mark.unit: Unit tests@pytest.mark.integration: Integration tests@pytest.mark.slow: Slow-running tests
How to Run Tests
Install Dependencies
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install project dependencies
poetry install
Run Tests
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov
# Run specific test types
poetry run pytest -m unit
poetry run pytest -m integration
poetry run pytest -m "not slow"
# Run specific test file
poetry run pytest tests/test_infrastructure.py
# Run with verbose output
poetry run pytest -v
Coverage Reports
- Terminal: Shows missing line coverage in terminal output
- HTML: Generates
htmlcov/index.htmlfor browser viewing - XML: Generates
coverage.xmlfor CI/CD integration
Validation
✅ All 14 validation tests pass, confirming:
- pytest framework works correctly
- Fixtures are properly configured
- Test discovery and markers function as expected
- Coverage reporting generates successfully
- Mock data structures work for graph-based testing
Dependencies Added
Production Dependencies
torch: Deep learning frameworknumpy: Numerical computingscikit-learn: Machine learning utilitiespandas: Data manipulationtqdm: Progress barstensorboardx: TensorBoard logging
Development Dependencies
pytest ^7.0.0: Testing frameworkpytest-cov ^4.0.0: Coverage reportingpytest-mock ^3.10.0: Mocking utilities
Notes
- Poetry lock file (
poetry.lock) is committed to ensure reproducible builds - Package mode is disabled since this is a research project, not a distributable package
- Coverage threshold is set to 80% but can be adjusted in
pyproject.toml - The infrastructure is designed to work with the existing GraphLoG codebase structure
Next Steps
Developers can now:
- Write unit tests in
tests/unit/ - Write integration tests in
tests/integration/ - Use the shared fixtures for consistent test data
- Generate coverage reports to track test completeness
- Run tests with various filtering options using the custom markers
🤖 Generated with Claude Code