feat: Set up comprehensive Python testing infrastructure with Poetry #90
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 SQLFlow client Python project using Poetry as the package manager and pytest as the testing framework. The setup provides a ready-to-use testing environment where developers can immediately start writing unit and integration tests.
Changes Made
Package Management
pyproject.tomlconfigurationrequirements.txt(mkdocs, mkdocs-material, etc.)pytest ^7.4.3- Main testing frameworkpytest-cov ^4.1.0- Coverage reportingpytest-mock ^3.12.0- Mocking utilitiesTesting Configuration
Configured pytest in
pyproject.tomlwith:test_*.pyand*_test.pyfilesunit,integration,slowConfigured coverage settings:
api/htmlcov/andcoverage.xmlDirectory Structure
Testing Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementsample_sql_query- Sample SQL for testingmock_config- Configuration dictionaryconfig_file- Temporary config file creationmock_http_client- HTTP client mockingmock_database_connection- Database connection mockingsample_api_response- API response examplessql_file- SQL file creationmock_env_vars- Environment variable setupmock_file_system- File system structure creationmock_logger- Logger mockingPoetry Scripts
Added convenient test commands:
poetry run test- Run all tests with coveragepoetry run tests- Alternative command (both work).gitignore Updates
Added entries for:
.pytest_cache/,.coverage,htmlcov/, etc.)dist/,*.egg-info/,build/).claude/*).vscode/,.idea/, vim swap files)How to Use
Install dependencies:
Run tests:
Run specific test categories:
Run tests without coverage:
View coverage report:
htmlcov/index.htmlin a browsercoverage.xmlfor CI integrationValidation
The infrastructure has been validated with 14 passing tests that verify:
poetry run testandpoetry run testscommands workNotes
pyproject.toml(both in pytest options and coverage settings) when real tests are added.api/directory is configured as the source for coverage tracking, assuming this is where the main Python code will reside.Next Steps
Developers can now:
tests/unit/tests/integration/