mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-12 00:54:16 +08:00
refactor: remove unused code
This commit is contained in:
@@ -119,52 +119,6 @@ def query_json(json_content, query, delimiter='.'):
|
|||||||
return json_content
|
return json_content
|
||||||
|
|
||||||
|
|
||||||
def deep_update_dict(origin_dict, override_dict):
|
|
||||||
""" update origin dict with override dict recursively
|
|
||||||
e.g. origin_dict = {'a': 1, 'b': {'c': 2, 'd': 4}}
|
|
||||||
override_dict = {'b': {'c': 3}}
|
|
||||||
return: {'a': 1, 'b': {'c': 3, 'd': 4}}
|
|
||||||
"""
|
|
||||||
if not override_dict:
|
|
||||||
return origin_dict
|
|
||||||
|
|
||||||
for key, val in override_dict.items():
|
|
||||||
if isinstance(val, dict):
|
|
||||||
tmp = deep_update_dict(origin_dict.get(key, {}), val)
|
|
||||||
origin_dict[key] = tmp
|
|
||||||
elif val is None:
|
|
||||||
# fix #64: when headers in test is None, it should inherit from config
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
origin_dict[key] = override_dict[key]
|
|
||||||
|
|
||||||
return origin_dict
|
|
||||||
|
|
||||||
|
|
||||||
def convert_dict_to_params(src_dict):
|
|
||||||
""" convert dict to params string
|
|
||||||
|
|
||||||
Args:
|
|
||||||
src_dict (dict): source mapping data structure
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: string params data
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
>>> src_dict = {
|
|
||||||
"a": 1,
|
|
||||||
"b": 2
|
|
||||||
}
|
|
||||||
>>> convert_dict_to_params(src_dict)
|
|
||||||
>>> "a=1&b=2"
|
|
||||||
|
|
||||||
"""
|
|
||||||
return "&".join([
|
|
||||||
"{}={}".format(key, value)
|
|
||||||
for key, value in src_dict.items()
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
def lower_dict_keys(origin_dict):
|
def lower_dict_keys(origin_dict):
|
||||||
""" convert keys in dict to lower case
|
""" convert keys in dict to lower case
|
||||||
|
|
||||||
|
|||||||
@@ -108,15 +108,6 @@ class TestUtils(ApiServerUnittest):
|
|||||||
functions_mapping["type_match"]({}, "dict")
|
functions_mapping["type_match"]({}, "dict")
|
||||||
functions_mapping["type_match"]({"a": 1}, "dict")
|
functions_mapping["type_match"]({"a": 1}, "dict")
|
||||||
|
|
||||||
def test_deep_update_dict(self):
|
|
||||||
origin_dict = {'a': 1, 'b': {'c': 3, 'd': 4}, 'f': 6, 'h': 123}
|
|
||||||
override_dict = {'a': 2, 'b': {'c': 33, 'e': 5}, 'g': 7, 'h': None}
|
|
||||||
updated_dict = utils.deep_update_dict(origin_dict, override_dict)
|
|
||||||
self.assertEqual(
|
|
||||||
updated_dict,
|
|
||||||
{'a': 2, 'b': {'c': 33, 'd': 4, 'e': 5}, 'f': 6, 'g': 7, 'h': 123}
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_handle_config_key_case(self):
|
def test_handle_config_key_case(self):
|
||||||
origin_dict = {
|
origin_dict = {
|
||||||
"Name": "test",
|
"Name": "test",
|
||||||
|
|||||||
Reference in New Issue
Block a user