Scope: set_channel_coupling() iterated items() and raised on every call

Connecting to the oscilloscope failed with "'list' object has no attribute
'upper'" whatever the IP was.  configure_channels() runs on connect and
sets the coupling on all four channels; set_channel_coupling() looped over
CHANNEL_COUPLING.items(), so `variants` was the whole ('AC', ['AC']) pair
and the comprehension called .upper() on the list half.  It raised before
looking at the value it was given, so no coupling could ever be accepted.

The tuple unpacking was dropped from `for long_form, variants in ...items()`
in 709dc529 without changing .items() to .values(); the four sibling
validators (acquire mode, trigger slope, trigger mode, data encoding) all
use .values().

The suite missed it because tests/fakes.py FakeScope replaces these setters
with recording stubs, so nothing exercised the real class.  The new test
drives TektronixOscilloscopeBase itself with only the socket replaced,
covering the connect-time path and the other validated setters alongside.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Thomas Ales
2026-09-08 09:17:23 -05:00
parent 92bbf02c8e
commit 43337bfa67
2 changed files with 72 additions and 1 deletions
+1 -1
View File
@@ -292,7 +292,7 @@ class TektronixOscilloscopeBase:
# Validate coupling
valid = False
for variants in self.CHANNEL_COUPLING.items():
for variants in self.CHANNEL_COUPLING.values():
if coupling_upper in [v.upper() for v in variants]:
valid = True
break