Skip to content

Commit f83aafa

Browse files
add new field for expect alternative values
1 parent e6b6a97 commit f83aafa

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

chaoslib/hypothesis.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,15 @@ def _(tolerance: dict, value: Any, configuration: Configuration = None,
332332
if not isinstance(expect, list):
333333
result = values == [expect]
334334
else:
335-
if len(values) == len(expect):
336-
for i,j in zip(values, expect):
337-
if isinstance(j, list):
338-
result = i in j
339-
else:
340-
if i == j:
341-
result = True
342-
else:
343-
result = False
344-
break
335+
result = values == expect
336+
337+
if "expect" in tolerance and result is False:
338+
expect_alt = tolerance.get("expect_alt")
339+
if "expect_alt" in tolerance:
340+
if not isinstance(expect_alt, list):
341+
result = values == [expect_alt]
345342
else:
346-
result = False
343+
result = values == expect_alt
347344

348345
if result is False:
349346
if "expect" in tolerance:
@@ -353,12 +350,6 @@ def _(tolerance: dict, value: Any, configuration: Configuration = None,
353350
else:
354351
logger.debug("jsonpath found '{}'".format(str(values)))
355352

356-
if result is True:
357-
if "expect" in tolerance:
358-
logger.debug(
359-
"jsonpath found '{}' and expected one of '{}'".format(
360-
str(values), str(tolerance["expect"])))
361-
362353
return result
363354
elif tolerance_type == "range":
364355
target = tolerance.get("target")

0 commit comments

Comments
 (0)