Select all entrances for results in one query

This commit is contained in:
Emily Love Watson
2025-08-21 11:35:23 -05:00
parent e916d27b7c
commit d0ad65f696
9 changed files with 72 additions and 92 deletions

View File

@@ -7,6 +7,7 @@
"""
Helper functions to compare expected values.
"""
import collections.abc
import json
import re
import math
@@ -102,8 +103,13 @@ class ResultAttr:
self.subobj = self.obj
for sub in self.key.split('+'):
done += f"[{sub}]"
assert sub in self.subobj, \
f"Missing attribute {done}. Full object:\n{_pretty(self.obj)}"
if isinstance(self.subobj, collections.abc.Sequence) and sub.isdigit():
sub = int(sub)
assert sub < len(self.subobj), \
f"Out of bound index {done}. Full object:\n{_pretty(self.obj)}"
else:
assert sub in self.subobj, \
f"Missing attribute {done}. Full object:\n{_pretty(self.obj)}"
self.subobj = self.subobj[sub]
def __eq__(self, other):