chore: Set up Python testing infrastructure with Poetry #124
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 Jetson.GPIO project using modern Python tooling. The setup migrates from traditional
setup.pyto Poetry for dependency management and configures pytest as the testing framework with coverage reporting.Changes Made
Package Management
pyproject.tomlwith all package metadata fromsetup.pyTesting Dependencies
Added as development dependencies:
pytest ^7.4.0- Core testing frameworkpytest-cov ^4.1.0- Coverage reporting integrationpytest-mock ^3.11.0- Mocking utilities for testsTesting Configuration
Configured in
pyproject.toml:tests/directory__init__.pyfrom coverageunit,integration, andslowmarkerspoetry run testandpoetry run testsworkDirectory Structure
Test Fixtures (in conftest.py)
temp_dir: Creates temporary directories for test filesmock_gpio_hardware: Mocks GPIO hardware interfacemock_gpio_permissions: Mocks GPIO permissions and sysfs pathsgpio_cleanup: Ensures GPIO cleanup after testsmock_config: Provides mock configurationsample_pin_data: Sample GPIO pin data for testingreset_modules: Resets imported modules between testsAdditional Updates
How to Use
Install Dependencies
Run Tests
View Coverage Reports
After running tests:
htmlcov/index.htmlin a browsercoverage.xmlfor CI integrationNotes
poetry.lockfile will be generated on first install and should be committed to ensure reproducible builds.Next Steps
Developers can now immediately start writing tests in the established structure. The validation tests confirm that all fixtures and configuration work correctly.