8000 feat: Add complete Python testing infrastructure with Poetry by llbbl · Pull Request #60 · google/hypernerf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add complete Python testing infrastructure with Poetry #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

llbbl
Copy link
@llbbl llbbl commented Jun 27, 2025

Add Complete Python Testing Infrastructure

Summary

This PR sets up a comprehensive testing infrastructure for the HyperNeRF project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and running tests with proper coverage reporting and custom configurat 9C55 ions.

Changes Made

Package Management

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

Testing Configuration

  • pytest Configuration:

    • Configured test discovery patterns
    • Set up coverage reporting with 80% threshold
    • Added custom markers: unit, integration, slow
    • Configured output formatting and strict options
  • Coverage Settings:

    • HTML and XML report generation
    • Source code coverage tracking
    • Exclusion patterns for test files and generated code

Project Structure

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

Testing Fixtures

Created comprehensive fixtures in conftest.py:

  • temp_dir: Temporary directory management
  • mock_config_file: Mock gin configuration files
  • sample_image_path: Test image generation
  • mock_camera_data: Camera parameter mocking
  • mock_dataset_config: Dataset configuration mocking
  • setup_test_environment: Auto-configure test environment
  • mock_jax_device: JAX device mocking for CPU testing
  • small_model_config: Lightweight model config for tests
  • capture_logs: Log capturing during tests

Additional Setup

  • Updated .gitignore: Added testing-related patterns, Claude settings, and common development files
  • Test Runner Script: Created run_tests.py as a fallback test runner
  • Validation Tests: Added tests to verify the infrastructure setup works correctly

How to Use

With Poetry (Recommended)

# Install dependencies
poetry install

# Run all tests
poetry run test
# or
poetry run tests

# Run with specific options
poetry run pytest -v
poetry run pytest tests/unit/
poetry run pytest -m unit

Without Poetry

# Use the provided test runner script
python run_tests.py

# Or run pytest directly after installing dependencies
pytest

Running Specific Test Types

# Run only unit tests
pytest -m unit

# Run only integration tests
pytest -m integration

# Skip slow tests
pytest -m "not slow"

# Run with coverage report
pytest --cov=hypernerf --cov-report=html

Notes

  • The Python version is constrained to >=3.8,<3.12 due to TensorFlow compatibility
  • Coverage threshold is set to 80% - tests will fail if coverage drops below this
  • All pytest standard options are available through the Poetry commands
  • The infrastructure is set up but no actual unit tests for the codebase are included - developers can now start writing tests immediately

Next Steps

  1. Install dependencies with poetry install
  2. Run validation tests to ensure setup works
  3. Start writing unit tests for core modules
  4. Add integration tests for key workflows
  5. Set up CI/CD to run tests automatically

- Set up Poetry as package manager with pyproject.toml configuration
- Migrate dependencies from requirements.txt and setup.py
- Add pytest, pytest-cov, and pytest-mock as dev dependencies
- Configure pytest with coverage reporting (80% threshold)
- Create test directory structure (unit/integration)
- Add comprehensive test fixtures in conftest.py
- Update .gitignore with testing and development patterns
- Create validation tests to verify infrastructure setup
- Add Poetry script commands for running 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
0