feat: Set up comprehensive Python testing infrastructure with Poetry#60
Open
llbbl wants to merge 1 commit intoJiahuiYu:masterfrom
Open
feat: Set up comprehensive Python testing infrastructure with Poetry#60llbbl wants to merge 1 commit intoJiahuiYu:masterfrom
llbbl wants to merge 1 commit intoJiahuiYu:masterfrom
Conversation
- Add Poetry configuration with testing dependencies (pytest, pytest-cov, pytest-mock) - Configure pytest with coverage reporting, test discovery, and custom markers - Create test directory structure with unit/integration subdirectories - Add comprehensive test fixtures in conftest.py for common testing needs - Update .gitignore with testing artifacts and Claude settings - Add validation tests to verify infrastructure setup - Configure Poetry scripts for running tests with 'poetry run test/tests'
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 comprehensive testing infrastructure for the AutoSlim project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and maintaining tests throughout the project.
Changes Made
Package Management
pyproject.tomlwith Poetry setup as the primary package managerTesting Configuration
pytest Configuration: Configured in
pyproject.tomlwith:test_*.pyand*_test.pyfilesCoverage Settings:
modelsandutilsdirectoriesDirectory Structure
Test Fixtures (conftest.py)
Created comprehensive fixtures including:
temp_dir: Temporary directory managementmock_config: Mock configuration objectsmock_model: Mock PyTorch modelsample_data: Sample tensor data (with fallback for non-torch environments)mock_dataset&mock_dataloader: Mock data loading utilitiesmock_optimizer&mock_loss_function: Mock training utilitiesmock_meter: Mock metrics trackingcapture_stdout: Stdout capture for testing print statementsmock_file_system: Mock file system structureenvironment_variables: Test environment setupAdditional Setup
Updated
.gitignorewith:.pytest_cache/,.coverage,htmlcov/,coverage.xml).claude/*)Added validation tests to ensure the infrastructure works correctly
How to Use
Running Tests
You can run tests using either of these commands:
poetry run test poetry run testsBoth commands are configured and will execute the same pytest runner.
Running Specific Test Types
Coverage Reports
After running tests, coverage reports are available in:
htmlcov/index.htmlin a browsercoverage.xmlfor CI/CD integrationNext Steps
Increase Coverage Threshold: Currently set to 0% in
pyproject.toml. As tests are added, increase the--cov-fail-undervalue to maintain code quality.Write Tests: The infrastructure is ready. Developers can now:
tests/unit/tests/integration/conftest.pyfor common testing scenariosCI/CD Integration: The setup is compatible with most CI/CD systems. The XML coverage report can be used for coverage tracking in CI pipelines.
Notes
sample_datafixture gracefully handles environments without PyTorch installed