feat: add comprehensive testing infrastructure with Poetry#28
Open
llbbl wants to merge 1 commit intodatawhalechina:masterfrom
Open
feat: add comprehensive testing infrastructure with Poetry#28llbbl wants to merge 1 commit intodatawhalechina:masterfrom
llbbl wants to merge 1 commit intodatawhalechina:masterfrom
Conversation
- Set up Poetry as package manager with pyproject.toml configuration - Add pytest, pytest-cov, and pytest-mock as dev dependencies - Configure pytest with markers (unit, integration, slow) and coverage settings - Create tests directory structure with conftest.py containing shared fixtures - Add validation tests to verify infrastructure setup - Update .gitignore with testing and build artifacts - Configure Poetry scripts for running tests with 'poetry run test[s]'
|
邮件已收到,祝好!
|
Author
|
不客气 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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