Skip to content

Commit 2f46af7

Browse files
nedsebCopilot
andauthored
Update tests/runner/mpremote_bridge.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 823c0cf commit 2f46af7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/runner/mpremote_bridge.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ def _driver_dir(self, driver_name):
6464
"""Return the local lib path for a driver."""
6565
return PROJECT_ROOT / "lib" / driver_name
6666

67-
def call_method(self, driver_name, driver_class, i2c_config, method, args=None):
67+
def call_method(self, driver_name, driver_class, i2c_config, method, args=None, i2c_address=None):
6868
"""Call a method on a driver instance and return the result."""
6969
args_str = ", ".join(repr(a) for a in (args or []))
7070
i2c_init = _i2c_init_code(i2c_config)
71+
if i2c_address is not None:
72+
dev_init = f"dev = {driver_class}(i2c, address={repr(i2c_address)})\n"
73+
else:
74+
dev_init = f"dev = {driver_class}(i2c)\n"
7175
code = (
7276
f"import json\n"
7377
f"{i2c_init}\n"
7478
f"from {driver_name}.device import {driver_class}\n"
75-
f"dev = {driver_class}(i2c)\n"
79+
f"{dev_init}"
7680
f"result = dev.{method}({args_str})\n"
7781
f"print(json.dumps(result))"
7882
)

0 commit comments

Comments
 (0)