feat: Add comprehensive Python testing infrastructure with Poetry #32
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.toml
setup.py
to modern Poetry configurationpoetry.lock
file 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_*.py
and*_test.py
filesunit
,integration
, andslow
markers 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
.gitignore
covering:Usage Instructions
Initial Setup
Running Tests
Writing New Tests
test_*.py
or*_test.py
tests/unit/
and integration tests intests/integration/
conftest.py
for common testing needs@pytest.mark.unit
,@pytest.mark.integration
, or@pytest.mark.slow
Notes
Next Steps