Skip to content

Commit ca5e4a5

Browse files
committed
tests: Address Copilot review on PR #111.
1 parent a790d1e commit ca5e4a5

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

lib/wsen-hids/wsen_hids/device.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,10 @@ def calibrate_temperature(self, ref_low, measured_low, ref_high, measured_high):
287287
ref_high: reference temperature at the high point (°C).
288288
measured_high: sensor reading at the high point (°C).
289289
"""
290-
self._temp_gain = float(ref_high - ref_low) / float(measured_high - measured_low)
290+
delta = float(measured_high - measured_low)
291+
if delta == 0.0:
292+
raise ValueError("measured_low and measured_high must differ")
293+
self._temp_gain = float(ref_high - ref_low) / delta
291294
self._temp_offset = float(ref_low) - self._temp_gain * float(measured_low)
292295

293296
# -------------------------------------------------------------------------

tests/runner/executor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ def run_action(action, driver_instance):
154154
return method(*args)
155155

156156
if action_type == "script":
157-
local_vars = {"dev": driver_instance}
158-
exec(action["script"], {}, local_vars)
159-
return local_vars.get("result")
157+
script_vars = {"dev": driver_instance, "i2c": driver_instance.i2c}
158+
exec(action["script"], script_vars, script_vars)
159+
if "result" not in script_vars:
160+
raise ValueError("Script must set a 'result' variable")
161+
return script_vars["result"]
160162

161163
if action_type == "hardware_script":
162164
# hardware_script is hardware-only; skip in mock mode

0 commit comments

Comments
 (0)