Fixed type_util.is_json_serializable with set objects.

This commit is contained in:
Fabio Caccamo 2020-02-19 15:14:22 +01:00
parent 7a4920705d
commit de6d6b13a8
2 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ def is_integer(val):
def is_json_serializable(val):
json_types = (type(None), bool, dict, float, list, tuple, set, ) + \
json_types = (type(None), bool, dict, float, list, tuple, ) + \
integer_types + string_types
return isinstance(val, json_types)

View File

@ -169,7 +169,7 @@ class type_util_test_case(unittest.TestCase):
self.assertFalse(f(datetime.now()))
self.assertTrue(f((0, 1, 2, )))
self.assertTrue(f([0, 1, 2]))
self.assertTrue(f(set([0, 1, 2])))
self.assertFalse(f(set([0, 1, 2])))
self.assertTrue(f({'a':0, 'b':1, 'c':2}))
self.assertTrue(f('hello world'))
self.assertFalse(f(lambda a: a))