feat: add comprehensive testing infrastructure with Poetry #28
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 Python Testing Infrastructure
Summary
This PR sets up a complete testing infrastructure for the PyTorch deep learning project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
pyproject.tomlwith Poetry configurationTesting Dependencies
pytest(v7.4.0) - Main testing frameworkpytest-cov(v4.1.0) - Coverage reportingpytest-mock(v3.11.1) - Mocking utilitiesTesting Configuration
✅ Configured pytest with:
test_*.pyand*_test.pyfilesunit,integration,slow✅ Configured coverage with:
code/directoryDirectory Structure
Shared Fixtures (conftest.py)
temp_dir- Temporary directory managementsample_config- Mock configuration dictionarymock_dataset_path- Creates mock dataset structuresample_tensor- Sample PyTorch tensors for testingsample_labels- Sample label tensorsdevice- Consistent device selection (CPU)reset_random_seeds- Reproducibility fixturemock_model_checkpoint- Mock model checkpoint creationcapture_stdout- Stdout capture for testing print statementsDevelopment Commands
poetry run test- Run all testspoetry run tests- Alternative command (both work)poetry run pytest -m unit- Run only unit testspoetry run pytest -m integration- Run only integration testspoetry run pytest -m slow- Run only slow testsAdditional Updates
.gitignorewith:.pytest_cache/,.coverage,htmlcov/, etc.).claude/*)How to Use
Install dependencies:
Run all tests:
Run specific test markers:
poetry run pytest -m unit poetry run pytest -m integration poetry run pytest -m "not slow"Generate coverage reports:
poetry run pytest --cov-report=html # View report at htmlcov/index.htmlValidation
The infrastructure has been validated with 15 passing tests that verify:
Notes