Allow array indices for assert_json_path()
This commit is contained in:
parent
e0c14aad4c
commit
5f7e482895
3
util.py
3
util.py
@ -135,6 +135,9 @@ def assert_json_path(res, path, value, err=None):
|
||||
|
||||
json_data = json.loads(res.text)
|
||||
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]
|
||||
|
||||
if json_data == value:
|
||||
|
Loading…
Reference in New Issue
Block a user