[tests:results] implement general tests for list items

This commit is contained in:
Mike Fährmann
2025-06-07 10:17:37 +02:00
parent fc01d85823
commit b95b71f63f
3 changed files with 39 additions and 5 deletions

View File

@@ -241,6 +241,12 @@ class TestExtractorResults(unittest.TestCase):
if key not in kwdict:
continue
if key.endswith("[*]"):
key = key[:-3]
subtest = True
else:
subtest = False
path = "{}.{}".format(parent, key) if parent else key
if key.startswith("!"):
@@ -248,7 +254,15 @@ class TestExtractorResults(unittest.TestCase):
continue
self.assertIn(key, kwdict, msg=path)
self._test_kwdict_value(kwdict[key], test, path)
value = kwdict[key]
if subtest:
self.assertNotIsInstance(value, str, msg=path)
for idx, item in enumerate(value):
subpath = "{}[{}]".format(path, idx)
self._test_kwdict_value(item, test, subpath)
else:
self._test_kwdict_value(value, test, path)
def _test_kwdict_value(self, value, test, path):
if isinstance(test, dict):