Skip to content

Conversation

@llbbl
Copy link

@llbbl llbbl commented Jun 29, 2025

Set Up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the depth upsampling and 3D object detection Python project. It modernizes the dependency management and creates a foundation for robust test-driven development.

Changes Made

Package Management

  • Migrated to Poetry: Replaced manual dependency management with Poetry
  • Consolidated dependencies: Merged requirements from depth_upsampling/requirements.txt and threedod/requirements.txt into pyproject.toml
  • Added testing dependencies: pytest, pytest-cov, and pytest-mock as development dependencies

Testing Configuration

  • Created pyproject.toml with complete testing configuration:
    • Pytest settings with strict markers and configurations
    • Coverage requirements set to 80% threshold
    • Test discovery patterns for test_*.py and *_test.py
    • Custom markers: unit, integration, and slow
    • Coverage reporting in multiple formats (terminal, HTML, XML)

Test Structure

  • Created organized test directory:
    tests/
    ├── __init__.py
    ├── conftest.py
    ├── test_setup_validation.py
    ├── unit/
    │   └── __init__.py
    └── integration/
        └── __init__.py
    

Pytest Fixtures

Created comprehensive fixtures in conftest.py:

  • General fixtures: temp_dir, mock_config, capture_logs
  • Image/Vision fixtures: sample_image, sample_depth_map, sample_point_cloud
  • PyTorch fixtures: sample_torch_tensor, mock_model, mock_dataset, mock_dataloader
  • 3D Detection fixtures: sample_bounding_boxes, sample_lidar_data
  • Environment fixtures: reset_environment (auto-use)

Development Commands

Configured Poetry scripts for running tests:

  • poetry run test - Run all tests
  • poetry run tests - Alternative command (both work)

Additional Updates

  • Updated .gitignore: Added testing artifacts, coverage reports, and Claude settings
  • Created validation tests: Comprehensive tests to verify the infrastructure works correctly

Instructions for Running Tests

  1. Install dependencies:

    poetry install
  2. Run all tests:

    poetry run test

    or

    poetry run tests
  3. Run specific test markers:

    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
  4. View coverage report:

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

Notes

  • The infrastructure is ready for immediate use - developers can start writing tests in the appropriate directories
  • Coverage threshold is set to 80% to encourage comprehensive testing
  • OpenCV may show import warnings in headless environments due to missing GUI libraries - this is handled in the validation tests
  • The raw directory was excluded from package configuration as it's not a proper Python package

- Added Poetry for modern dependency management
- Configured pytest with coverage reporting (80% threshold)
- Created test directory structure with unit/integration separation
- Added comprehensive pytest fixtures for project needs
- Configured pytest markers for test categorization
- Updated .gitignore with testing and Claude-related entries
- Added validation tests to verify infrastructure setup
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