tests: add test framework with mock and hardware support.#28
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a YAML-driven pytest framework to validate MicroPython drivers both on CPython (mocked I2C) and on real hardware via mpremote, with optional Markdown report generation and CI coverage for mock tests (closes #27).
Changes:
- Introduces a generic scenario runner (
tests/test_scenarios.py) that auto-discoverstests/scenarios/*.yamland supports--driver/--port. - Adds hardware execution support via an
mpremotebridge plus a FakeI2C/FakePin CPython shim for mock runs. - Adds a pytest Markdown report plugin and a GitHub Actions workflow to run mock tests in CI; updates README with Testing/Contributing guidance.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_scenarios.py | Generic YAML scenario discovery + execution for mock/hardware/manual modes. |
| tests/scenarios/hts221.yaml | First full driver scenario (HTS221) covering mock, hardware, and manual checks. |
| tests/runner/mpremote_bridge.py | mpremote execution bridge to run driver calls / raw register reads on-device. |
| tests/runner/executor.py | Scenario action execution + driver loading/cleanup for mock runs on CPython. |
| tests/report_plugin.py | Pytest plugin generating Markdown summary + per-driver reports. |
| tests/fake_machine/i2c.py | Fake I2C bus implementation for CPython-based driver tests. |
| tests/fake_machine/pin.py | Fake Pin implementation for CPython-based driver tests. |
| tests/fake_machine/micropython_stub.py | Minimal micropython.const() stub for CPython. |
| tests/fake_machine/init.py | Exposes fake machine components for test harness. |
| tests/conftest.py | Adds pytest options (--port, --driver) and enables the report plugin. |
| tests/requirements-test.txt | Declares test dependencies for local installation. |
| pytest.ini | Configures pytest testpaths and markers used by the framework. |
| .github/workflows/tests.yml | CI workflow to run mock tests on push/PR. |
| .github/workflows/requirements.txt | Adds pyyaml pin for workflow dependency installs. |
| README.md | Documents how to run mock/hardware/manual tests and generate reports; expands contributing guidance. |
| reports/.gitkeep | Keeps reports/ directory present for report output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f944691 to
c4bb669
Compare
c4bb669 to
e0f9a35
Compare
This was referenced Mar 11, 2026
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
tests.yml) running mock tests on every push/PR--driverand--portpytest options for targeted testingdisplaysupport, auto-skipped in non-interactive modehts221.yaml(8 tests: mock + hardware + manual)Usage
Closes #27