def test_set_nonexistent_parent_nested(self): obj = {} path_dict = PathDictAccess(obj) path_dict.set('foo.bar.baz', 42) self.assertEqual(obj, {'foo': {'bar': {'baz': 42}}})
def test_nested_set(self): obj = {'foo': {}} path_dict = PathDictAccess(obj) path_dict.set('foo.bar', 42) self.assertEqual(obj, {'foo': {'bar': 42}})
def test_set_index(self): obj = {'foo': [None, {'bar': 0}]} path_dict = PathDictAccess(obj) path_dict.set('foo[1].bar', 42) self.assertEqual(obj, {'foo': [None, {'bar': 42}]})
def test_simple_set(self): obj = {} path_dict = PathDictAccess(obj) path_dict.set('foo', 42) self.assertEqual(obj, {'foo': 42})