fix: print_info value is None

TypeError: unsupported format string passed to NoneType.__format__
This commit is contained in:
debugtalk
2019-04-17 21:06:42 +08:00
parent eeb7eade1a
commit 2342bcade8
2 changed files with 14 additions and 0 deletions

View File

@@ -385,6 +385,8 @@ def print_info(info_mapping):
continue
elif isinstance(value, (dict, list)):
value = json.dumps(value)
elif value is None:
value = "None"
if is_py2:
if isinstance(key, unicode):

View File

@@ -263,3 +263,15 @@ class TestUtils(ApiServerUnittest):
parameters_content_list = []
product_list = utils.gen_cartesian_product(*parameters_content_list)
self.assertEqual(product_list, [])
def test_print_info(self):
info_mapping = {
"a": 1,
"t": (1, 2),
"b": {
"b1": 123
},
"c": None,
"d": [4, 5]
}
utils.print_info(info_mapping)