RenderPipeline
RenderPipeline copied to clipboard
feat: Add comprehensive Python testing infrastructure with Poetry
Add Python Testing Infrastructure to RenderPipeline
Summary
This PR establishes a comprehensive testing infrastructure for the RenderPipeline project using modern Python tooling. The setup enables developers to immediately start writing tests with proper dependency management, test discovery, and coverage reporting.
Changes Made
Package Management
- Poetry Configuration: Added
pyproject.tomlwith Poetry setup in package-mode=false (dependency management only) - Dependencies Migrated: Identified and migrated core dependencies (Panda3D, PyYAML, colorama, progressbar2, six)
- Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies
- Optional GUI Dependencies: PyQt5 configured as optional dependency group
Testing Configuration
-
pytest Configuration:
- Test discovery patterns for
test_*.pyand*_test.pyfiles - Coverage reporting with HTML, XML, and terminal output
- Custom markers:
unit,integration,slow - Strict mode enabled for better error detection
- Test discovery patterns for
-
Coverage Settings:
- Source paths:
rpcore,rpplugins,rplibs - Excluded: test files, samples, toolkit, cache directories
- Multiple report formats (HTML, XML, terminal)
- Currently set to 0% threshold (should be adjusted as tests are added)
- Source paths:
Test Infrastructure
-
Directory Structure:
tests/ ├── __init__.py ├── conftest.py # Shared fixtures and configuration ├── unit/ # Unit tests directory │ └── __init__.py ├── integration/ # Integration tests directory │ └── __init__.py └── test_setup_validation.py # Infrastructure validation tests -
Shared Fixtures (in
conftest.py):temp_dir: Temporary directory managementmock_panda3d: Mock Panda3D modules for testing without installationsample_config: Sample configuration dictionariesconfig_file: Temporary YAML config filesmock_render_pipeline: Mock RenderPipeline instancemock_light,mock_plugin,mock_texture: Common mock objectssample_shader_code: Sample GLSL shader codecapture_logs: Log capture utility- Auto-setup of test environment with proper Python paths
Additional Updates
.gitignoreUpdates: Added patterns for:- Testing artifacts (
.pytest_cache/,.coverage,htmlcov/, etc.) - Poetry/package management files
- Virtual environments
- IDE files
- Claude settings (
.claude/*)
- Testing artifacts (
How to Use
Installation
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
poetry install
# Install optional GUI dependencies
poetry install --with gui
Running Tests
# Run all tests
poetry run pytest
# Run with verbose output
poetry run pytest -v
# Run specific test file
poetry run pytest tests/test_setup_validation.py
# Run tests by marker
poetry run pytest -m unit
poetry run pytest -m "not slow"
# Run with coverage report
poetry run pytest --cov-report=html
# Then open htmlcov/index.html in a browser
Writing Tests
- Create test files in
tests/unit/ortests/integration/ - Use the provided fixtures from
conftest.py - Mark tests appropriately:
@pytest.mark.unit def test_something(): pass @pytest.mark.integration @pytest.mark.slow def test_complex_integration(): pass
Notes
- The project uses bundled dependencies in
rplibs/, which are included in the coverage reports - Coverage threshold is currently set to 0% to allow infrastructure setup; this should be increased as tests are added
- The yaml_py2 modules show parsing warnings due to Python 2 syntax but don't affect functionality
- Poetry is configured in non-package mode since RenderPipeline isn't distributed as a package
Future Improvements
- Increase coverage threshold as more tests are added
- Add pre-commit hooks for running tests
- Consider adding tox for testing across multiple Python versions
- Add CI/CD integration for automated testing