From fa55f672dfe9e20cadfef5b4ac8bb14a691277f8 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Wed, 22 Apr 2020 19:54:01 -0300 Subject: Clean up tests a bit more --- testing/test_abdl.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'testing/test_abdl.py') 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 "" -- cgit 1.4.1