Ejemplo n.º 1
0
def test_parse_list():
    trait = List(Float)
    x = [1.0, 1.5, 2.0]
    for y in [ parse_list(trait, '[1.0,1.5,2.0]'),
               parse_list(trait, '(1.0, 1.5, 2.0)'),
               parse_list(trait, '1.0,1.5,2.0') ]:
        assert_equal(x, y)
Ejemplo n.º 2
0
def test_nested_sequence():
    trait = List(List(Int))
    x = [[1, 2], [3, 4]]
    for y in [ parse_list(trait, '[[1, 2], [3, 4]]'),
               parse_list(trait, '[1,2],[3,4]') ]:
        assert_equal(x, y)

    trait = Dict(Str, List(Int))
    assert_equal(dict(foo=[1,2], bar=[3,4]),
                 parse_dict(trait, 'foo: [1,2], bar: [3,4]'))