feat: Set up comprehensive Python testing infrastructure with Poetry #93
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.
Set Up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Ovis project, migrating from traditional setuptools to Poetry for modern dependency management and adding a complete pytest-based testing framework.
Changes Made
Package Management Migration
pyproject.toml
with Poetry configurationrequirements.txt
^3.9
to meet accelerate package requirementsxformers
dependency temporarily commented out due to build issuesTesting Framework Setup
pytest
(^8.0.0) - Core testing frameworkpytest-cov
(^5.0.0) - Coverage reportingpytest-mock
(^3.14.0) - Mocking utilitiesTesting Configuration
Pytest configuration in
pyproject.toml
:test_*.py
and*_test.py
unit
,integration
,slow
Coverage configuration:
ovis
__init__.py
Directory Structure
Shared Fixtures (conftest.py)
temp_dir
: Temporary directory managementmock_config
: Sample configuration dictionarysample_tensor
: PyTorch tensor for testingsample_text_data
: Text data for NLP testsmock_model
: Mock PyTorch modelmock_tokenizer
: Mock tokenizersample_image_path
: Temporary image file creationenvironment_variables
: Safe environment variable managementmock_api_response
: API response mockingreset_random_seeds
: Automatic seed reset for reproducibilitycapture_logs
: Log message capture during testsDevelopment Commands
Both commands are configured to run the full test suite:
poetry run test
poetry run tests
Updated .gitignore
Added comprehensive entries for:
.pytest_cache/
,.coverage
,htmlcov/
, etc.).claude/*
)poetry.lock
is NOT ignored (as required)Instructions for Running Tests
Install dependencies:
Run all tests:
Run specific test categories:
View coverage report:
htmlcov/index.html
in a browsercoverage.xml
for CI integrationNotes
Coverage Threshold: Currently set to 0% to allow initial setup validation. Should be changed to 80% in
pyproject.toml
once actual tests are written:--cov-fail-under=80
fail_under = 80
xformers: This dependency is commented out due to build issues. It may need special installation instructions or system dependencies.
Validation Tests: The included
test_setup_validation.py
verifies that all testing infrastructure components are working correctly. These tests can be removed once real tests are added.Next Steps
tests/unit/
andtests/integration/
directoriesThe testing infrastructure is now ready for immediate use!