feat: Add comprehensive Python testing infrastructure with Poetry #80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Comprehensive Python Testing Infrastructure
Summary
This PR establishes a modern testing infrastructure for the iTracker PyTorch implementation using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing unit and integration tests with comprehensive coverage reporting.
Changes Made
Package Management
pyproject.toml
with complete Poetry configurationrequirements.txt
to PoetryTesting Configuration
Test Structure
Shared Fixtures (conftest.py)
Created comprehensive fixtures for testing iTracker components:
temp_dir
: Temporary directory managementmock_config
: Configuration dictionary for testingsample_image
,sample_face_image
,sample_eye_images
: Test image generationsample_face_grid
,sample_gaze_target
: Mock tensor datamock_dataset_metadata
: Dataset metadata for testingmock_model_checkpoint
: Model checkpoint creationdevice
: PyTorch device selection (CPU/CUDA)random_seed
: Reproducible test executionmock_dataloader_batch
: Mock DataLoader batchTest Markers
@pytest.mark.unit
: For unit tests@pytest.mark.integration
: For integration tests@pytest.mark.slow
: For slow-running testsGit Configuration
Updated
.gitignore
with:How to Use
Running Tests
Install Poetry (if not already installed):
Install dependencies:
cd pytorch poetry install
Run tests:
Writing New Tests
tests/unit/
directorytests/integration/
directoryconftest.py
for common test dataCoverage Reports
htmlcov/
directorycoverage.xml
for CI integrationNotes
pytorch/
directoryNext Steps
With this infrastructure in place, the team can now:
@pytest.mark.slow
marker