Skip to content

Commit 262bff5

Browse files
add expect_one_of feature in jsonpath tolerance
Signed-off-by: saravanan palanisamy <saravanan30erd@gmail.com>
1 parent f781dfe commit 262bff5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

chaoslib/hypothesis.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,18 @@ def _(tolerance: dict, value: Any, configuration: Configuration = None,
332332
if not isinstance(expect, list):
333333
result = values == [expect]
334334
else:
335-
result = values == expect
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
345+
else:
346+
result = False
336347

337348
if result is False:
338349
if "expect" in tolerance:
@@ -342,6 +353,9 @@ def _(tolerance: dict, value: Any, configuration: Configuration = None,
342353
else:
343354
logger.debug("jsonpath found '{}'".format(str(values)))
344355

356+
logger.debug(
357+
"jsonpath found '{}' but expected '{}'".format(
358+
str(values), str(tolerance["expect"])))
345359
return result
346360
elif tolerance_type == "range":
347361
target = tolerance.get("target")

0 commit comments

Comments
 (0)