Skip to content

Conversation

@llbbl
Copy link

@llbbl llbbl commented Sep 2, 2025

Set up Complete Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the ORACLE project, providing developers with a ready-to-use environment for writing and running tests.

Changes Made

Package Manager Setup

  • Configured Poetry as the package manager with pyproject.toml
  • Migrated dependencies from existing requirements files (requirements_cuda10_1.txt, requirements_cuda11.txt)
  • Simplified initial dependencies to core packages (numpy, matplotlib, scipy) for stable setup
  • Added development dependencies: pytest, pytest-cov, pytest-mock

Testing Configuration

  • Comprehensive pytest configuration in pyproject.toml:
    • Test discovery patterns for multiple test file formats
    • Coverage reporting with 80% threshold
    • HTML and XML coverage report generation
    • Custom markers: unit, integration, slow
    • Strict configuration and comprehensive output options

Directory Structure

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

Shared Test Fixtures (tests/conftest.py)

  • File system fixtures: temp_dir, temp_file
  • Configuration fixtures: sample_config, sample_waypoints
  • Mock fixtures: mock_ros_node, mock_tensorflow, mock_tensorrt, mock_opencv
  • Data fixtures: sample_depth_image, sample_state_vector
  • Utility fixtures: captured_logs, environment_variables, mock_file_system
  • Auto-cleanup fixture: clean_imports to prevent test state leakage

Coverage Configuration

  • Source tracking for the entire project
  • Intelligent exclusions: tests, cache, build artifacts, model weights
  • Comprehensive exclude patterns for common non-testable code patterns
  • Multiple report formats: terminal, HTML (htmlcov/), XML (coverage.xml)

Project Files

  • Updated .gitignore with comprehensive testing, development, and Claude Code entries
  • Validation tests to verify the entire infrastructure works correctly

Testing Infrastructure Features

Running Tests

# Install dependencies
poetry install

# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov

# Run specific test types
poetry run pytest -m unit          # Unit tests only
poetry run pytest -m integration   # Integration tests only  
poetry run pytest -m "not slow"    # Skip slow tests

# Run with verbose output
poetry run pytest -v

Coverage Reporting

  • 80% coverage threshold (configurable in pyproject.toml)
  • HTML reports generated in htmlcov/ directory
  • XML reports for CI/CD integration
  • Terminal output with missing line indicators

Custom Test Markers

  • @pytest.mark.unit - Fast, isolated tests
  • @pytest.mark.integration - Tests requiring multiple components
  • @pytest.mark.slow - Time-consuming tests (can be skipped)

Validation Results

16 validation tests passed, 1 skipped (expected - TensorFlow not installed)
All fixtures working correctly
Coverage reporting functional
Custom markers properly configured
Poetry dependency management working

Next Steps for Developers

  1. Install dependencies: poetry install
  2. Start writing tests in tests/unit/ and tests/integration/
  3. Use existing fixtures from conftest.py or add new ones as needed
  4. Run tests frequently during development
  5. Maintain coverage above 80% threshold

Dependencies Note

The initial setup includes only core dependencies (numpy, matplotlib, scipy) to ensure stable installation. Additional project-specific dependencies from the original requirements files (TensorFlow, OpenCV, ROS packages, etc.) can be added incrementally as needed for specific test scenarios.

Configuration Files

  • pyproject.toml - Complete Poetry and pytest configuration
  • .gitignore - Comprehensive exclusions for Python development
  • tests/conftest.py - Shared fixtures and test utilities

🤖 Generated with Claude Code

- Add Poetry package manager with pyproject.toml configuration
- Configure pytest with coverage reporting and custom markers
- Create testing directory structure (tests/, unit/, integration/)
- Add comprehensive shared fixtures in conftest.py
- Include validation tests to verify infrastructure works
- Set up .gitignore with testing and development entries
- Configure coverage thresholds and reporting formats

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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