feat: Add comprehensive Python testing infrastructure with Poetry #19
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: