autotest: allow assertion of mavlink message array elements

This commit is contained in:
Thomas Watson 2024-11-29 16:45:38 -06:00 committed by Thomas Watson
parent 190c3aa7ab
commit 6abbefde12
1 changed files with 7 additions and 1 deletions

View File

@ -4364,6 +4364,12 @@ class TestSuite(ABC):
def message_has_field_values(self, m, fieldvalues, verbose=True, epsilon=None):
for (fieldname, value) in fieldvalues.items():
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