Skip to content

Conversation

@llbbl
Copy link

@llbbl llbbl commented Jun 29, 2025

Python Testing Infrastructure Setup

Summary

This PR establishes a comprehensive testing infrastructure for the project using Poetry as the package manager and pytest as the testing framework. The setup provides a ready-to-use environment where developers can immediately start writing unit and integration tests.

Changes Made

Package Management

  • Poetry Configuration: Created pyproject.toml with Poetry as the package manager
  • Dependency Migration: Migrated existing dependencies from requirements.txt
  • Lock File: Generated poetry.lock for reproducible installations

Testing Framework

  • pytest: Main testing framework with plugins:
    • pytest-cov: Coverage reporting with HTML and XML output
    • pytest-mock: Mocking utilities for test isolation
  • Configuration: Comprehensive pytest settings in pyproject.toml:
    • Test discovery patterns
    • Coverage thresholds (currently 0%, should be updated to 80% after writing tests)
    • Custom markers for test categorization
    • Strict mode and verbose output

Directory Structure

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

Shared Fixtures (conftest.py)

  • temp_dir: Temporary directory with automatic cleanup
  • mock_config: Mock configuration dictionary
  • sample_point_cloud: Test 3D point cloud data
  • sample_image_data: Test image arrays
  • mock_camera_params: Camera parameter fixtures
  • temp_ply_file: Temporary PLY file generation
  • mock_training_args: Training argument mocks
  • capture_stdout: Stdout capturing for testing prints
  • reset_random_seed: Reproducible random seeds
  • mock_gaussian_model_data: Gaussian model test data
  • environment_setup: Test environment configuration

Development Workflow

  • Commands: Both poetry run test and poetry run tests work
  • Markers: Tests can be marked as @pytest.mark.unit, @pytest.mark.integration, or @pytest.mark.slow
  • Coverage: Automatic coverage reporting in HTML and XML formats

Additional Setup

  • CLAUDE.md: Created project context file for Claude Code
  • .gitignore: Updated with comprehensive Python testing patterns

Instructions for Running Tests

  1. Install Poetry (if not already installed):

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

    poetry install
  3. Run Tests:

    poetry run test
    # or
    poetry run tests
  4. Run Specific Test Categories:

    poetry run pytest -m unit        # Run only unit tests
    poetry run pytest -m integration # Run only integration tests
    poetry run pytest -m "not slow"  # Skip slow tests
  5. View Coverage Report:

    • HTML report: Open htmlcov/index.html in a browser
    • Terminal report: Automatically displayed after test run
    • XML report: Available at coverage.xml for CI integration

Important Notes

  • Coverage Threshold: Currently set to 0% to allow infrastructure setup. Update line 44 in pyproject.toml from "--cov-fail-under=0" to "--cov-fail-under=80" after writing actual tests.
  • Dependencies: Some packages (open3d, pytorch3d) were excluded due to platform compatibility issues. These can be added back with platform-specific configurations if needed.
  • Poetry Lock: The poetry.lock file is tracked in git for reproducible builds.

Next Steps

  1. Write unit tests for individual modules in tests/unit/
  2. Write integration tests for system components in tests/integration/
  3. Update coverage threshold to 80% once tests are written
  4. Configure CI/CD to run tests automatically

- Configured Poetry as package manager with pyproject.toml
- Added pytest, pytest-cov, and pytest-mock as dev dependencies
- Set up pytest configuration with coverage reporting
- Created test directory structure (unit/integration)
- Added shared fixtures in conftest.py
- Configured test markers (unit, integration, slow)
- Added Poetry scripts for running tests
- Created validation tests to verify setup
- Updated .gitignore with testing artifacts
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