diff options
-rw-r--r-- | testing/test_abdl.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/testing/test_abdl.py b/testing/test_abdl.py index 0307623..d28658a 100644 --- a/testing/test_abdl.py +++ b/testing/test_abdl.py @@ -25,23 +25,19 @@ objtree = st.deferred(lambda: st.text() | st.dictionaries(hashables, values) | s # note: use all() so as to not eat all the RAM :p class LogAndCompare: - def __init__(self, left, right): + def __init__(self, *iterables): self.log = [] - self.iter = self.genny(left, right) - def genny(self, left, right): + self._iters = iterables + def __iter__(self): def wrap_exc(it): try: for x in it: yield x except abdl.ValidationError as e: yield e - for (l, r) in itertools.zip_longest(wrap_exc(left), wrap_exc(right), fillvalue=object()): - self.log.append((l, r)) - yield l == r or (type(l), type(r)) == (abdl.ValidationError,)*2 - def __iter__(self): - return self - def __next__(self): - return next(self.iter) + for res in itertools.zip_longest(*map(wrap_exc, self._iters), fillvalue=object()): + self.log.append(res) + yield all(x == res[0] for x in res) or all(type(x) == abdl.ValidationError for x in res) def __repr__(self): return "<LogAndCompare(log=" + repr(self.log) + ")>" |