feat: Set up comprehensive Python testing infrastructure with Poetry and pytest #70
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 Python project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and running tests across the codebase.
Changes Made
Package Management
pyproject.toml
with project metadata and dependenciespoetry.lock
file for reproducible buildsTesting Framework
Configuration
pyproject.toml
includes:test_*.py
and*_test.py
files@pytest.mark.unit
,@pytest.mark.integration
,@pytest.mark.slow
Directory Structure
Shared Fixtures (conftest.py)
temp_dir
: Creates temporary directories for testingtemp_file
: Creates temporary files with contentmock_config
: Provides mock configuration objectsmock_logger
: Mock logger for testing loggingsample_data
: Common test data structuresenv_vars
: Temporarily set environment variablesmock_file_system
: Mock file system operationscapture_stdout
: Capture print outputmock_requests
: Mock HTTP requestsDevelopment Experience
.gitignore
with comprehensive Python patternspoetry run test
- Run all testspoetry run tests
- Alternative command (both work)How to Use
Installation
Running Tests
Writing Tests
tests/unit/
ortests/integration/
conftest.py
for common functionality@pytest.mark.unit
, etc.test_*.py
for test filesCoverage Configuration
Coverage settings are pre-configured but not enforced by default. To run with coverage:
This will:
htmlcov/
coverage.xml
Next Steps
With this infrastructure in place, developers can now:
@pytest.mark.slow
The validation tests confirm that all components are working correctly and can be run anytime to verify the setup.