def test_merge_from_1(): a = OmegaConf.empty() b = OmegaConf.from_string(''' a : 1 b : 2 ''') a.merge_from(b) assert a == b
def test_merge_from_2(): a = OmegaConf.empty() a.inner = {} b = OmegaConf.from_string(''' a : 1 b : 2 ''') a.inner.merge_from(b) assert a.inner == b
def test_setattr_deep_from_empty(): c = OmegaConf.empty() # Unfortunately we can't just do c.a.b = 9 here. # The reason is that if c.a is being resolved first and it does not exist, so there # is nothing to call .b = 9 on. # The alternative is to auto-create fields as they are being accessed, but this is opening # a whole new can of worms, and is also breaking map semantics. c.a = {} c.a.b = 9 assert {'a': {'b': 9}} == c
def test_create_empty__deprecated(): assert OmegaConf.empty() == {}
def test_update_with_empty_map_value(): c = OmegaConf.empty() c.update('a', {}) assert {'a': {}} == c
def test_subscript_set(): c = OmegaConf.empty() c['a'] = 'b' assert {'a': 'b'} == c
def test_is_empty(): c = OmegaConf.from_string('a: b') assert not c.is_empty() c = OmegaConf.empty() assert c.is_empty()
def test_update_deep_with_value(): c = OmegaConf.empty() c.update('a.b', 1) assert {'a': {'b': 1}} == c
def test_update_deep_from_empty(): c = OmegaConf.empty() c.update('a.b', 1) assert {'a': {'b': 1}} == c
def test_update_with_map_value(): c = OmegaConf.empty() c.update('a', {'aa': 1, 'bb': 2}) assert {'a': {'aa': 1, 'bb': 2}} == c