diff --git a/httprunner/compat.py b/httprunner/compat.py index fb63cf58..3c8112c6 100644 --- a/httprunner/compat.py +++ b/httprunner/compat.py @@ -18,7 +18,9 @@ def convert_jmespath(raw: Text) -> Text: raw_list = [] for item in raw.split("."): 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}"') elif item.isdigit(): # convert lst.0.name to lst[0].name diff --git a/tests/compat_test.py b/tests/compat_test.py index 282582d9..9722013d 100644 --- a/tests/compat_test.py +++ b/tests/compat_test.py @@ -11,6 +11,9 @@ class TestCompat(unittest.TestCase): self.assertEqual( compat.convert_jmespath("headers.Content-Type"), 'headers."Content-Type"' ) + self.assertEqual( + compat.convert_jmespath('headers."Content-Type"'), 'headers."Content-Type"' + ) self.assertEqual( compat.convert_jmespath("body.data.buildings.0.building_id"), "body.data.buildings[0].building_id",