mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +08:00
fix: compatibility with jmespath, headers."Content-Type"
This commit is contained in:
@@ -18,7 +18,9 @@ def convert_jmespath(raw: Text) -> Text:
|
|||||||
raw_list = []
|
raw_list = []
|
||||||
for item in raw.split("."):
|
for item in raw.split("."):
|
||||||
if "-" in item:
|
if "-" in item:
|
||||||
# add quotes for field with separator, e.g. headers.Content-Type
|
# add quotes for field with separator
|
||||||
|
# e.g. headers.Content-Type => headers."Content-Type"
|
||||||
|
item = item.strip('"')
|
||||||
raw_list.append(f'"{item}"')
|
raw_list.append(f'"{item}"')
|
||||||
elif item.isdigit():
|
elif item.isdigit():
|
||||||
# convert lst.0.name to lst[0].name
|
# convert lst.0.name to lst[0].name
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ class TestCompat(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
compat.convert_jmespath("headers.Content-Type"), 'headers."Content-Type"'
|
compat.convert_jmespath("headers.Content-Type"), 'headers."Content-Type"'
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
compat.convert_jmespath('headers."Content-Type"'), 'headers."Content-Type"'
|
||||||
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
compat.convert_jmespath("body.data.buildings.0.building_id"),
|
compat.convert_jmespath("body.data.buildings.0.building_id"),
|
||||||
"body.data.buildings[0].building_id",
|
"body.data.buildings[0].building_id",
|
||||||
|
|||||||
Reference in New Issue
Block a user