EnlightenGAN
EnlightenGAN copied to clipboard
feat: Set up comprehensive Python testing infrastructure with Poetry
Add Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the Python project using Poetry as the package manager and pytest as the testing framework. The setup provides a ready-to-use testing environment where developers can immediately start writing tests.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith Poetry as the package manager - Dependency Migration: Migrated existing dependencies from
requirement.txtto Poetry - Lock File: Generated
poetry.lockto ensure reproducible builds
Testing Dependencies
Added the following testing tools as development dependencies:
pytest- Modern testing frameworkpytest-cov- Coverage reporting pluginpytest-mock- Mocking utilities
Testing Configuration
Configured pytest in pyproject.toml with:
- Test discovery patterns
- Coverage reporting with 80% threshold
- HTML and XML coverage reports
- Strict markers and configuration
- Custom test markers:
unit,integration,slow
Directory Structure
Created organized testing structure:
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_setup_validation.py # Infrastructure validation
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Fixtures
Created comprehensive fixtures in conftest.py:
temp_dir- Temporary directory managementmock_config- Mock configuration objectssample_image_tensor- Test image tensorsmock_dataset- Mock dataset for testingmock_dataloader- Mock dataloadercleanup_gpu- GPU memory cleanupmock_visdom- Mocked visualizationsample_options- Sample command line options- And more...
Additional Setup
- Updated
.gitignorewith testing artifacts and Claude settings - Created validation tests to verify the infrastructure works correctly
How to Use
Installing Dependencies
poetry install
Running Tests
You can run tests using either:
poetry run pytest
Running Tests with Coverage
Coverage is enabled by default:
poetry run pytest
Running Specific Test Types
# Run only unit tests
poetry run pytest -m unit
# Run only integration tests
poetry run pytest -m integration
# Exclude slow tests
poetry run pytest -m "not slow"
Coverage Reports
- HTML report:
htmlcov/index.html - XML report:
coverage.xml - Terminal report: Shown after test run
Notes
- The project uses Poetry in non-package mode since it's not a distributable package
- Coverage threshold is set to 80% - tests will fail if coverage drops below this
- All test-related files are properly gitignored except the lock file
- The infrastructure is ready for immediate use - developers can start writing tests right away
Validation
All validation tests pass successfully:
- ✅ Testing dependencies installed
- ✅ Directory structure created
- ✅ Fixtures available and working
- ✅ Test markers configured
- ✅ Coverage reporting configured