mirror of https://github.com/ArduPilot/ardupilot
autotest: allow assertion of mavlink message array elements
This commit is contained in:
parent
190c3aa7ab
commit
6abbefde12
|
@ -4364,7 +4364,13 @@ class TestSuite(ABC):
|
||||||
|
|
||||||
def message_has_field_values(self, m, fieldvalues, verbose=True, epsilon=None):
|
def message_has_field_values(self, m, fieldvalues, verbose=True, epsilon=None):
|
||||||
for (fieldname, value) in fieldvalues.items():
|
for (fieldname, value) in fieldvalues.items():
|
||||||
got = getattr(m, fieldname)
|
if "[" in fieldname: # fieldname == "arrayname[index]"
|
||||||
|
assert fieldname[-1] == "]", fieldname
|
||||||
|
arrayname, index = fieldname.split("[", 1)
|
||||||
|
index = int(index[:-1])
|
||||||
|
got = getattr(m, arrayname)[index]
|
||||||
|
else:
|
||||||
|
got = getattr(m, fieldname)
|
||||||
|
|
||||||
value_string = value
|
value_string = value
|
||||||
got_string = got
|
got_string = got
|
||||||
|
|
Loading…
Reference in New Issue