KittiSeg
KittiSeg copied to clipboard
feat: Add comprehensive Python testing infrastructure with Poetry
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 managementmock_config: Sample configuration dictionarysample_image: Creates test RGB imagessample_label_image: Creates test segmentation imageskitti_data_structure: Mock KITTI dataset structuremock_hypes_file: Test configuration filesnumpy_array_2d/4d: Sample numpy arraysreset_environment: Environment variable isolationcapture_logs: Log capture for testing
Additional Updates
- Updated
.gitignorewith 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.xmlfor 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