[tests/results] improve '{…, …, ...}' tests

fix error when including 'dict' type as possible result
This commit is contained in:
Mike Fährmann
2025-11-11 21:20:33 +01:00
parent c07421cba6
commit 76081b312e
2 changed files with 9 additions and 6 deletions

View File

@@ -23,9 +23,9 @@ __tests__ = (
"filename" : str,
"count" : 6,
"num" : range(1, 5),
# "source" : {None, dict},
"source" : {None, dict},
"block" : {
# "attachment" : {None, dict},
"attachment" : {None, dict},
"base_class" : "Block",
"class" : {"Link", "Attachment", "Image"},
"comment_count" : 0,

View File

@@ -310,10 +310,13 @@ class TestExtractorResults(unittest.TestCase):
elif isinstance(test, range):
self.assertRange(value, test, msg=path)
elif isinstance(test, set):
try:
self.assertIn(value, test, msg=path)
except AssertionError:
self.assertIn(type(value), test, msg=path)
for item in test:
if isinstance(item, type) and isinstance(value, item) or \
value == item:
break
else:
v = type(value) if len(str(value)) > 64 else value
self.fail(f"{v!r} not in {test}: {path}")
elif isinstance(test, list):
subtest = False
for idx, item in enumerate(test):