feat: Add comprehensive Python testing infrastructure with Poetry#87
Open
llbbl wants to merge 1 commit intoalibaba:mainfrom
Open
feat: Add comprehensive Python testing infrastructure with Poetry#87llbbl wants to merge 1 commit intoalibaba:mainfrom
llbbl wants to merge 1 commit intoalibaba:mainfrom
Conversation
- Set up Poetry as package manager with pyproject.toml configuration - Add pytest, pytest-cov, and pytest-mock as dev dependencies - Configure pytest with coverage reporting (HTML/XML) and custom markers - Create proper test directory structure (unit/integration) - Add comprehensive test fixtures in conftest.py - Update .gitignore with testing and Claude-specific entries - Create validation tests to verify infrastructure setup - Configure Poetry scripts for 'test' and 'tests' commands Note: Coverage threshold temporarily set to 0% for infrastructure setup. Should be changed to 80% when implementing actual tests. Decord package temporarily commented out due to installation issues.
|
|
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.
Python Testing Infrastructure Setup
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 infrastructure is now ready for developers to immediately start writing tests.
Changes Made
Package Management
pyproject.tomlwith full Poetry configurationrequirements.txtto Poetrypytest,pytest-cov, andpytest-mockas development dependenciesTesting Configuration
pytest Configuration:
unit,integration, andslowtestsCoverage Settings:
models,utils,stable_lorahtmlcov/), and XML (coverage.xml)Directory Structure
Test Fixtures (in conftest.py)
temp_dir: Temporary directory with automatic cleanupmock_config: Mock OmegaConf configurationsample_image_path: Mock image file pathsample_video_path: Mock video file pathmock_model_weights: Mock model weights fileenvironment_setup: Test environment variablesmock_dataset_config: Mock dataset configurationmock_training_args: Mock training argumentscleanup_cuda_cache: Automatic CUDA cache cleanupDevelopment Commands
Both commands work identically and run the full test suite:
poetry run test poetry run testsAdditional Updates
.gitignorewith testing-related entries and.claude/*How to Use
Install dependencies:
Run tests:
Run specific test markers:
View coverage report:
htmlcov/index.htmlin a browsercoverage.xmlfor CI/CD integrationNotes
Coverage Threshold: Currently set to 0% to allow infrastructure setup to pass. When you start adding actual tests, update these values in
pyproject.toml:--cov-fail-under=0to--cov-fail-under=80fail_under = 0tofail_under = 80Decord Package: The
decordpackage is temporarily commented out in dependencies due to installation issues. It may need platform-specific installation or alternative packaging.Poetry Lock File: The
poetry.lockfile is NOT gitignored and should be committed to ensure reproducible builds.Next Steps
The testing infrastructure is now ready. Developers can:
tests/unit/tests/integration/