feat: Add complete Python testing infrastructure with Poetry #23
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 complete testing infrastructure for the shootback project using Poetry as the package manager and pytest as the testing framework. The infrastructure is ready for developers to immediately start writing unit and integration tests.
Changes Made
Package Management
pyproject.tomlwith Poetry configuration as the project's package managerpackage-mode = false) since shootback uses only standard library^3.7to ensure compatibility with modern testing toolsTesting Dependencies
Added as development dependencies:
pytest(^7.4.0) - Main testing frameworkpytest-cov(^4.1.0) - Coverage reportingpytest-mock(^3.11.1) - Mocking utilitiesTesting Configuration
Configured in
pyproject.toml:test_*.pyand*_test.pyfilesunit- For unit testsintegration- For integration testsslow- For slow-running testsDirectory Structure
Shared Fixtures (
conftest.py)temp_dir- Temporary directory for test filesmock_socket- Mock socket objectmock_ssl_context- Mock SSL contextfree_port- Find available port for testingmock_config- Sample configuration dictionarymock_logger- Mock logger for testingthread_cleanup- Ensure threads are cleaned upmock_threading_event- Mock threading Eventsample_binary_data/sample_text_data- Test datamock_server_socket- Mock server socketreset_modules- Reset singleton modules between testsPoetry Scripts
poetry run test- Run all testspoetry run tests- Alternative command (both work)Updated
.gitignoreAdded entries for:
.pytest_cache/,.coverage,htmlcov/, etc.).claude/*)poetry.lockis NOT ignored (should be committed)How to Use
Install dependencies:
Run all tests:
Run specific test types:
View coverage report:
htmlcov/index.htmlin browsercoverage.xml(for CI/CD integration)Validation
The setup includes
test_setup_validation.pywhich verifies:All validation tests pass successfully.
Notes
pyproject.toml