Skip to content

feat: Add comprehensive Python testing infrastructure with Poetry#210

Open
llbbl wants to merge 1 commit intoMarvinTeichmann:masterfrom
UnitSeeker:add-testing-infrastructure
Open

feat: Add comprehensive Python testing infrastructure with Poetry#210
llbbl wants to merge 1 commit intoMarvinTeichmann:masterfrom
UnitSeeker:add-testing-infrastructure

Conversation

@llbbl
Copy link
Copy Markdown

@llbbl llbbl commented Jun 27, 2025

Add Python Testing Infrastructure

Summary

This PR sets up a comprehensive testing infrastructure for the KittiSeg project using modern Python tooling. The setup provides a solid foundation for writing and running tests with proper coverage reporting.

Changes Made

Package Management

  • Poetry configured as the package manager via pyproject.toml
  • Migrated existing dependencies from requirements.txt
  • Added development dependencies for testing

Testing Framework

  • pytest as the main testing framework
  • pytest-cov for coverage reporting with 80% threshold
  • pytest-mock for mocking utilities

Configuration

  • Comprehensive pytest configuration in pyproject.toml:
    • Test discovery patterns
    • Coverage settings with HTML and XML reports
    • Custom markers for unit, integration, and slow tests
    • Strict mode enabled for better error detection

Directory Structure

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

Testing Fixtures (in conftest.py)

  • temp_dir: Temporary directory management
  • mock_config: Sample configuration dictionary
  • sample_image: Creates test RGB images
  • sample_label_image: Creates test segmentation images
  • kitti_data_structure: Mock KITTI dataset structure
  • mock_hypes_file: Test configuration files
  • numpy_array_2d/4d: Sample numpy arrays
  • reset_environment: Environment variable isolation
  • capture_logs: Log capture for testing

Additional Updates

  • Updated .gitignore with testing artifacts and Claude settings
  • Created validation tests to verify the infrastructure works correctly

Usage Instructions

Install Dependencies

# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -

# Install project dependencies
poetry install

Running Tests

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

# Run with specific markers
poetry run pytest -m unit
poetry run pytest -m integration
poetry run pytest -m "not slow"

# Run specific test file
poetry run pytest tests/test_infrastructure_validation.py

# Run with different verbosity
poetry run pytest -q  # quiet
poetry run pytest -v  # verbose

Coverage Reports

  • Terminal: Shown automatically after test runs
  • HTML: Generated in htmlcov/ directory
  • XML: Generated as coverage.xml for CI integration

Notes

  • The coverage threshold is set to 80% but can be adjusted in pyproject.toml
  • The validation tests verify that all fixtures and configurations work correctly
  • No actual unit tests for the codebase were written - this PR only sets up the infrastructure
  • Poetry lock file (poetry.lock) should be committed to ensure reproducible builds

- Set up Poetry as package manager with pyproject.toml configuration
- Add pytest, pytest-cov, and pytest-mock as dev dependencies
- Configure pytest with coverage reporting (80% threshold)
- Create tests/ directory structure with unit and integration subdirs
- Add comprehensive conftest.py with reusable fixtures
- Include validation tests to verify infrastructure works
- Update .gitignore with testing and Claude-related entries
- Add test commands: poetry run test/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