From 0b8d2b1471f9e37918f29a890d81ae6bf1057792 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 29 May 2020 11:03:32 +0800 Subject: [PATCH] fix: compatibility with jmespath, headers."Content-Type" --- httprunner/compat.py | 4 +++- tests/compat_test.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) 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",