Skip to content

Conversation

@llbbl
Copy link

@llbbl llbbl commented Jun 16, 2025

Set Up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the threedgrut project using Poetry as the package manager and pytest as the testing framework.

Changes Made

Package Management

  • Poetry Configuration: Created pyproject.toml with Poetry configuration
  • Dependency Migration: Migrated all dependencies from requirements.txt to Poetry format
  • Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies

Testing Framework Setup

  • pytest Configuration:

    • Configured test discovery patterns
    • Set coverage threshold to 80%
    • Added HTML and XML coverage reporting
    • Configured strict mode and verbose output
    • Added custom test markers: unit, integration, slow
  • Coverage Configuration:

    • Source directories: all project packages
    • Exclusions: test files, cache, setup files
    • Report formats: terminal, HTML, XML
    • Precision: 2 decimal places

Directory Structure

tests/
├── __init__.py
├── conftest.py          # Shared fixtures
├── test_infrastructure.py  # Validation tests
├── unit/
│   └── __init__.py
└── integration/
    └── __init__.py

Shared Fixtures (conftest.py)

  • temp_dir: Temporary directory for test files
  • temp_file: Temporary file creation
  • sample_config: Sample OmegaConf configuration
  • mock_dataset_path: Mock dataset directory structure
  • mock_checkpoint_path: Mock checkpoint file
  • mock_ply_file: Mock PLY point cloud file
  • mock_camera_params: Camera parameter fixtures
  • mock_render_params: Render parameter fixtures
  • clean_environment: Environment variable cleanup
  • mock_wandb: Disable wandb during tests
  • change_test_dir: Auto-change to temp directory
  • sample_point_cloud: Sample point cloud data
  • gpu_available/skip_if_no_gpu: GPU availability checks
  • mock_timer: Timer mocking for performance tests

Additional Setup

  • Poetry Scripts: Added poetry run test and poetry run tests commands
  • .gitignore Updates: Added testing-related entries and Claude settings

Usage Instructions

  1. Install Poetry (if not already installed):

    curl -sSL https://install.python-poetry.org | python3 -
  2. Install Dependencies:

    poetry install
  3. Run Tests:

    # Run all tests
    poetry run test
    # or
    poetry run tests
    
    # Run with specific markers
    poetry run pytest -m unit
    poetry run pytest -m "not slow"
    
    # Run specific test file
    poetry run pytest tests/test_infrastructure.py
  4. View Coverage Reports:

    • Terminal: Automatically displayed after test run
    • HTML: Open htmlcov/index.html
    • XML: Available at coverage.xml

Validation

The infrastructure has been validated with a comprehensive test suite (test_infrastructure.py) that verifies:

  • Python version requirements
  • Fixture functionality
  • Test markers
  • Coverage tracking
  • Mock capabilities
  • Environment isolation

Notes

  • The project requires Python 3.11+
  • Coverage threshold is set to 80% (configurable in pyproject.toml)
  • Some dependencies may require system packages for compilation (especially PyTorch-related)
  • The infrastructure is ready for developers to start writing unit and integration tests

Next Steps

Developers can now:

  1. Write unit tests in tests/unit/
  2. Write integration tests in tests/integration/
  3. Use the provided fixtures for common testing scenarios
  4. Run tests with coverage to ensure code quality

- Add Poetry package manager configuration with all dependencies
- Configure pytest with coverage reporting (80% threshold)
- Create test directory structure with unit/integration separation
- Add comprehensive shared fixtures in conftest.py
- Configure test markers (unit, integration, slow)
- Update .gitignore with testing and Poetry entries
- Add validation tests to verify infrastructure setup
- Configure Poetry scripts for 'test' and 'tests' commands
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