def test_set(): a = {True, 5.5, 5, None, 'hello'} s = Serializer() r = s.serialize(a) # sets are unordered, and, it turns out, not deterministic # TODO bit of a bodge r = sorted([str(x) for x in r]) assert r == ['5', '5.5', 'None', 'True', 'hello']
def test_from_import(): from emw_serializer import JsonSerializer, Serializer js = JsonSerializer() s = Serializer()
def test_string(): a = 'hello' s = Serializer() r = s.serialize(a) assert r == 'hello'
def test_int(): a = 5 s = Serializer() r = s.serialize(a) assert r == 5
def test_float(): a = 5.5 s = Serializer() r = s.serialize(a) assert r == 5.5
def test_bool(): a = True s = Serializer() r = s.serialize(a) assert r is True
def test_list(): a = [True, 5.5, 5, None, 'hello'] s = Serializer() r = s.serialize(a) assert r == [True, 5.5, 5, None, 'hello']