feat: Set up comprehensive Python testing infrastructure with Poetry #88
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 ModelCache project, migrating from pip/requirements.txt to Poetry for dependency management and setting up pytest as the testing framework.
Changes Made
Package Management Migration
pyproject.tomlwith Poetry configurationrequirements.txtto Poetrypytest,pytest-cov,pytest-mockTesting Configuration
pytest configuration in
pyproject.toml:test_*.pyand*_test.pyfilesunit,integration,slowCoverage configuration:
modelcacheandmodelcache_mmpackagesDirectory Structure
Shared Fixtures (conftest.py)
temp_dir: Temporary directory for test filesmock_config: Mock configuration dictionarymock_embedding: Mock embedding objectmock_cache_manager: Mock cache managersample_vector_data: Sample 768-dimensional vector datamock_redis_client: Mock Redis clientmock_milvus_client: Mock Milvus clientsample_text_data: Sample text data for testingmock_http_response: Mock HTTP responsereset_environment: Auto-reset environment variablesTesting Commands
After installing dependencies with
poetry install, you can run tests using:poetry run test- Run all testspoetry run tests- Alternative command (both work)poetry run pytest- Direct pytest executionpoetry run pytest -m unit- Run only unit testspoetry run pytest -m integration- Run only integration testspoetry run pytest --cov-report=html- Generate HTML coverage reportAdditional Updates
.gitignorewith:.pytest_cache/,htmlcov/,coverage.xml).claude/*)poetry.lockwhich should be committed)How to Use
Install Poetry if not already installed:
curl -sSL https://install.python-poetry.org | python3 -Install dependencies:
Run tests:
poetry run testView coverage report:
Notes
test_setup_validation.py) verify that the testing infrastructure is properly configuredNext Steps
With this infrastructure in place, developers can now:
tests/unit/directorytests/integration/directory