예제 #1
0
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()
예제 #3
0
def test_string():
    a = 'hello'
    s = Serializer()
    r = s.serialize(a)
    assert r == 'hello'
예제 #4
0
def test_int():
    a = 5
    s = Serializer()
    r = s.serialize(a)
    assert r == 5
예제 #5
0
def test_float():
    a = 5.5
    s = Serializer()
    r = s.serialize(a)
    assert r == 5.5
예제 #6
0
def test_bool():
    a = True
    s = Serializer()
    r = s.serialize(a)
    assert r is True
예제 #7
0
def test_list():
    a = [True, 5.5, 5, None, 'hello']
    s = Serializer()
    r = s.serialize(a)
    assert r == [True, 5.5, 5, None, 'hello']