def test_map_dot_set(d): m = Map(**d) m.A = 11 m.a = 'one' m.z = {'Z': {'omega': 20}} assert m.a == 'one' assert m.A == 11 assert m.z.Z.omega == 20 assert isinstance(m.z, Map) assert isinstance(m.z.Z, Map)
def test_map_dot_set(d): m = Map(**d) m.A = 11 m.a = 'one' m.z = {'Z': {'omega': 20}} assert m.a == 'one' assert m.A == 11 assert m.z.Z.omega == 20 assert isinstance(m.z, Map) assert isinstance(m.z.Z, Map)
def test_dict_hashing(): d2 = Map(a=Map(b=3), c=5) d3 = Map(a=Map(b=6), c=5) c = {} c[d2.a] = d2 c[d3.a] = d3 assert c[d2.a] == d2 assert c[d3.a] == d3
def test_map_dot_get(d): m = Map(**d) assert m.a == 1 assert m.c.e.f == 6 assert m.b[0].j == 9 assert m.b[1].g == 7 assert isinstance(m.b, list) assert isinstance(m.b[1], Map)
def test_map_get(d): m = Map(**d) assert m['a'] == 1 assert m['c']['e']['f'] == 6 assert m['b'][0]['j'] == 9 assert m['b'][1]['g'] == 7 assert isinstance(m['b'], list) assert isinstance(m['b'][1], Map)
def test_map_set(d): m = Map(**d) m['A'] = 11 m['a'] = 'one' m['z'] = {'Z': {'omega': 20}} assert m['a'] == 'one' assert m['A'] == 11 assert m['z']['Z']['omega'] == 20 assert isinstance(m['z'], Map) assert isinstance(m['z']['Z'], Map)
def test_hash(): d1 = Map(a=Map(b=3), c=5) d2 = Map(a=Map(b=3), c=5) d3 = Map(a=Map(b=6), c=5) assert hash(d1) == hash(d2) assert hash(d1) != hash(d3) assert hash(d2) != hash(d3)
def test_map_init(d): m = Map(**d) assert isinstance(m, Map) assert isinstance(m, dict)