mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +08:00
bugfix: keys that are not in 'request' of config shall not be lower cased
This commit is contained in:
@@ -51,7 +51,7 @@ class Runner(object):
|
||||
@param (str) context level, testcase or testset
|
||||
"""
|
||||
# convert keys in request headers to lowercase
|
||||
config_dict = utils.lower_dict_key(config_dict)
|
||||
config_dict = utils.lower_config_dict_key(config_dict)
|
||||
|
||||
self.context.init_context(level)
|
||||
self.context.config_context(config_dict, level)
|
||||
|
||||
13
ate/utils.py
13
ate/utils.py
@@ -300,7 +300,7 @@ def lower_dict_key(origin_dict, depth=1):
|
||||
new_dict = {}
|
||||
|
||||
for key, value in origin_dict.items():
|
||||
if depth > 2:
|
||||
if depth >= 2:
|
||||
new_dict[key] = value
|
||||
continue
|
||||
|
||||
@@ -311,6 +311,17 @@ def lower_dict_key(origin_dict, depth=1):
|
||||
|
||||
return new_dict
|
||||
|
||||
def lower_config_dict_key(config_dict):
|
||||
""" convert key in config dict to lower case, convertion will occur in two places:
|
||||
1, all keys in config dict;
|
||||
2, all keys in config["request"]
|
||||
"""
|
||||
config_dict = lower_dict_key(config_dict)
|
||||
if "request" in config_dict and isinstance(config_dict["request"], dict):
|
||||
config_dict["request"] = lower_dict_key(config_dict["request"])
|
||||
|
||||
return config_dict
|
||||
|
||||
def convert_to_order_dict(map_list):
|
||||
""" convert mapping in list to ordered dict
|
||||
@param (list) map_list
|
||||
|
||||
@@ -222,7 +222,7 @@ class TestUtils(ApiServerUnittest):
|
||||
self.assertFalse(utils.is_variable(("os", os)))
|
||||
self.assertFalse(utils.is_variable(("utils", utils)))
|
||||
|
||||
def test_lower_dict_key(self):
|
||||
def test_handle_config_key_case(self):
|
||||
origin_dict = {
|
||||
"Name": "test",
|
||||
"Request": {
|
||||
@@ -234,7 +234,7 @@ class TestUtils(ApiServerUnittest):
|
||||
}
|
||||
}
|
||||
}
|
||||
new_dict = utils.lower_dict_key(origin_dict)
|
||||
new_dict = utils.lower_config_dict_key(origin_dict)
|
||||
self.assertIn("name", new_dict)
|
||||
self.assertIn("request", new_dict)
|
||||
self.assertIn("method", new_dict["request"])
|
||||
|
||||
Reference in New Issue
Block a user