Allow array indices for assert_json_path()
This commit is contained in:
1 parent
a73847454f
commit
d89c0ccf64
1 file changed
+3
@@ -135,6 +135,9 @@ def assert_json_path(res, path, value, err=None):
|
|||||||
|
|
||||||
json_data = json.loads(res.text)
|
json_data = json.loads(res.text)
|
||||||
for key in filter(None, path.split(".")):
|
for key in filter(None, path.split(".")):
|
||||||
|
match = re.match(r"\[([0-9]+)\]", key)
|
||||||
|
if match:
|
||||||
|
key = int(match[1])
|
||||||
json_data = json_data[key]
|
json_data = json_data[key]
|
||||||
|
|
||||||
if json_data == value:
|
if json_data == value:
|
||||||
|
|||||||
Reference in new issue
Block a user