feat: Add comprehensive Python testing infrastructure with Poetry#19
Open
llbbl wants to merge 1 commit intoquentinhardy:masterfrom
Open
feat: Add comprehensive Python testing infrastructure with Poetry#19llbbl wants to merge 1 commit intoquentinhardy:masterfrom
llbbl wants to merge 1 commit intoquentinhardy:masterfrom
Conversation
- Set up Poetry as package manager with pyproject.toml configuration - Migrate dependencies from requirements.txt to Poetry - Add pytest, pytest-cov, and pytest-mock as dev dependencies - Configure pytest with coverage reporting (HTML/XML outputs) - Create test directory structure with unit/integration subdirectories - Add comprehensive shared fixtures in conftest.py - Update .gitignore with testing and Claude-related entries - Add poetry run test/tests commands for convenience
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 MSDAT project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and running tests with coverage reporting.
Changes Made
Package Management
pyproject.tomlwith Poetry configurationrequirements.txtto PoetryTesting Configuration
pytest Configuration:
Coverage Configuration:
Directory Structure
Shared Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementtemp_file- Temporary file creationmock_config- Mock configuration dictionarymock_database_connection- Mock database connection and cursormock_argparse_args- Mock command line argumentsmock_logger- Mock logger objectsample_sql_results- Sample SQL query resultsmock_file_system- Mock file system structuremock_network_response- Mock network responsesreset_modules- Module reset between testscapture_output- Stdout/stderr capturemock_progressbar- Mock progress barenvironment_variables- Temporary environment variable managementmock_color_output- Mock colored terminal outputOther Updates
poetry run testandpoetry run testscommandsHow to Use
Install dependencies:
Run all tests:
Run specific test files:
Run tests with specific markers:
View coverage report:
htmlcov/index.htmlin a browsercoverage.xmlNotes
Validation
The setup has been validated with a comprehensive test file (
test_setup_validation.py) that verifies: