Skip to content

feat: Add comprehensive Python testing infrastructure#5

Open
llbbl wants to merge 1 commit intofpour:mainfrom
UnitSeeker:add-testing-infrastructure
Open

feat: Add comprehensive Python testing infrastructure#5
llbbl wants to merge 1 commit intofpour:mainfrom
UnitSeeker:add-testing-infrastructure

Conversation

@llbbl
Copy link

@llbbl llbbl commented Sep 2, 2025

Python Testing Infrastructure Setup

Summary

This PR establishes a complete testing infrastructure for the Temporal Graph Networks project, providing a robust foundation for writing and running tests across all modules (TGN, TGAT, CAW, EdgeBank).

Changes Made

Package Management

  • Poetry Configuration: Set up pyproject.toml with Poetry as the package manager
  • Dependency Migration: Consolidated dependencies from existing requirements.txt files
  • Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies

Testing Configuration

  • pytest Settings: Configured test discovery, coverage thresholds (80%), and output formats
  • Coverage Reporting: HTML (htmlcov/) and XML (coverage.xml) reports with proper exclusions
  • Custom Markers: Added unit, integration, and slow markers for test categorization

Directory Structure

tests/
├── __init__.py
├── conftest.py          # Shared fixtures and test utilities
├── unit/
│   └── __init__.py
├── integration/
│   └── __init__.py
└── test_setup_validation.py  # Infrastructure validation tests

Shared Fixtures

The conftest.py includes commonly needed fixtures:

  • temp_dir: Temporary directory management
  • sample_data: Sample graph data DataFrames
  • sample_graph_edges: Sample edge arrays
  • mock_model_config: Mock configuration dictionaries
  • sample_csv_file: Temporary CSV file creation
  • mock_device and mock_args: Test utilities

Git Configuration

  • Updated .gitignore with testing artifacts, coverage reports, model checkpoints, and Claude Code settings
  • Preserved poetry.lock for dependency reproducibility

Running Tests

Basic Commands

# Run all tests
poetry run pytest

# Run with verbose output
poetry run pytest -v

# Run specific test categories
poetry run pytest -m unit
poetry run pytest -m integration
poetry run pytest -m slow

# Run with coverage reporting
poetry run pytest --cov=tgn --cov=tgat --cov=CAW --cov=EdgeBank

Coverage Reports

  • Terminal: Coverage summary displayed after test runs
  • HTML: Open htmlcov/index.html for detailed interactive reports
  • XML: coverage.xml for CI/CD integration

Validation

All infrastructure components have been tested:

  • ✅ pytest discovers and runs tests correctly
  • ✅ Coverage reporting generates HTML and XML outputs
  • ✅ Custom markers (unit, integration, slow) work properly
  • ✅ Shared fixtures provide expected test utilities
  • ✅ pytest-mock integration functions correctly

Next Steps

Developers can now:

  1. Write unit tests in tests/unit/ for individual module testing
  2. Write integration tests in tests/integration/ for cross-module functionality
  3. Use the shared fixtures from conftest.py for consistent test data
  4. Run tests with comprehensive coverage reporting
  5. Leverage custom markers to categorize and selectively run tests

The testing infrastructure is ready for immediate use with proper dependency management, configuration, and validation.

- Set up Poetry package manager with pyproject.toml configuration
- Add pytest, pytest-cov, and pytest-mock as development dependencies
- Configure pytest with coverage reporting (80% threshold, HTML/XML output)
- Create tests/ directory structure with unit/ and integration/ subdirectories
- Add shared fixtures in conftest.py for common testing utilities
- Update .gitignore with testing artifacts and Claude Code settings
- Include custom pytest markers (unit, integration, slow)
- Validate setup with comprehensive infrastructure tests
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