Skip to content

vl53l1x: Add test scenario for distance sensor.#46

Merged
nedseb merged 2 commits intomainfrom
tests/vl53l1x-scenario
Mar 12, 2026
Merged

vl53l1x: Add test scenario for distance sensor.#46
nedseb merged 2 commits intomainfrom
tests/vl53l1x-scenario

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 12, 2026

Closes #37

Summary

  • Add YAML test scenario for VL53L1X ToF distance sensor with 16-bit register addresses
  • Add **kwargs to FakeI2C methods to support addrsize=16 parameter
  • Add machine.lightsleep stub in executor for VL53L1X mock compatibility

Test commands

# Mock tests (CPython)
python3 -m pytest tests/ -v --driver vl53l1x

# Hardware tests (STeaMi board)
python3 -m pytest tests/ -v --port /dev/ttyACM0 --driver vl53l1x -s

Test results

============================== test session starts ==============================
platform linux -- Python 3.13.7, pytest-8.3.5, pluggy-1.5.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/nedjar/sandbox/micropython-steami-lib
configfile: pytest.ini
plugins: typeguard-4.4.2
collected 50 items                                                                                                                                                                                                                                                          

tests/test_scenarios.py::test_scenario[vl53l1x/Verify model ID register/mock] 0xEACC
PASSED
tests/test_scenarios.py::test_scenario[vl53l1x/Verify model ID register/hardware] 0xEACC
PASSED
tests/test_scenarios.py::test_scenario[vl53l1x/Read distance returns integer/mock] 250
PASSED
tests/test_scenarios.py::test_scenario[vl53l1x/Distance in plausible range/hardware] 1680
PASSED
tests/test_scenarios.py::test_scenario[vl53l1x/Distance measurement feels correct/hardware]   Distance: 1678 mm
  [MANUAL] La distance mesurée est-elle cohérente (objet devant le capteur) ? [y/n] y
True
PASSED

============================== 5 passed in 12.93s ===============================

@nedseb nedseb changed the title vl53l1x: Add test scenario for distance sensor vl53l1x: Add test scenario for distance sensor. Mar 12, 2026
@nedseb nedseb requested review from Charly-sketch and Copilot March 12, 2026 11:06
@nedseb nedseb self-assigned this Mar 12, 2026
@nedseb nedseb added enhancement New feature or request test labels Mar 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new YAML-based scenario test for the VL53L1X ToF distance sensor and updates the CPython mock environment so the driver can run under the existing scenario test framework.

Changes:

  • Added tests/scenarios/vl53l1x.yaml covering model-ID verification (mock/hardware), a mock distance read, and hardware/manual distance checks.
  • Extended FakeI2C memory methods to accept keyword arguments (needed for drivers that pass addrsize=16).
  • Stubbed machine.lightsleep in the mock executor to support VL53L1X driver initialization on CPython.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/scenarios/vl53l1x.yaml New scenario definition for VL53L1X mock/hardware/manual tests.
tests/runner/executor.py Adds machine.lightsleep stub to improve MicroPython-API compatibility in mock mode.
tests/fake_machine/i2c.py Updates FakeI2C method signatures to tolerate addrsize kwarg used by VL53L1X (16-bit register addressing).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/fake_machine/i2c.py Outdated
Comment thread tests/scenarios/vl53l1x.yaml Outdated
@nedseb nedseb merged commit 595003b into main Mar 12, 2026
3 checks passed
@nedseb nedseb deleted the tests/vl53l1x-scenario branch March 15, 2026 14:31
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: Add test scenario for VL53L1X distance sensor.

2 participants