feat: Add comprehensive Python testing infrastructure with Poetry#32
Open
llbbl wants to merge 1 commit intoPanJinquan:masterfrom
Open
feat: Add comprehensive Python testing infrastructure with Poetry#32llbbl wants to merge 1 commit intoPanJinquan:masterfrom
llbbl wants to merge 1 commit intoPanJinquan:masterfrom
Conversation
- Set up Poetry as package manager with pyproject.toml configuration - Add pytest, pytest-cov, and pytest-mock as development dependencies - Configure pytest with coverage reporting (80% threshold) - Create tests directory structure with shared fixtures in conftest.py - Add custom pytest markers (unit, integration, slow) - Configure Poetry scripts for running tests (test/tests commands) - Add comprehensive .gitignore for Python projects - Include validation tests to verify infrastructure works correctly
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 TensorFlow-Slim models project, providing developers with all the tools needed to write and run tests effectively.
Changes Made
Package Management
pyproject.tomlsetup.pyto modern Poetry configurationpoetry.lockfile for reproducible buildsTesting Dependencies
Added the following development dependencies:
pytest ^7.4.0- Modern Python testing frameworkpytest-cov ^4.1.0- Coverage reporting plugin for pytestpytest-mock ^3.11.0- Mocking utilities for pytestTesting Configuration
Configured in
pyproject.toml:test_*.pyand*_test.pyfilesunit,integration, andslowmarkers for test categorizationDirectory Structure
Created organized testing structure:
Shared Fixtures (conftest.py)
Comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementmock_image_file- Creates test imagesmock_model_checkpoint- Mock TensorFlow checkpointsmock_tfrecord_file- Mock TFRecord filesmock_labels_file- Label file generationmock_config- Configuration dictionariesmock_dataset_split- Dataset directory structurescapture_logs- Log capture utilitiesmock_env_vars- Environment variable mockingcleanup_files- File cleanup trackingDevelopment Commands
Configured Poetry scripts for convenience:
poetry run test- Run all testspoetry run tests- Alternative command (both work identically)Both commands support all standard pytest options (e.g.,
-v,-k,-m, etc.)Version Control
Added comprehensive
.gitignorecovering:Usage Instructions
Initial Setup
Running Tests
Writing New Tests
test_*.pyor*_test.pytests/unit/and integration tests intests/integration/conftest.pyfor common testing needs@pytest.mark.unit,@pytest.mark.integration, or@pytest.mark.slowNotes
Next Steps