def test_source_setdefault_as_subsection(): config = DictSource() with pytest.raises(AttributeError): config.a.b = 1 config.setdefault('a', {}).b = 1 assert config.a.b == 1
def test_source_setdefault(): config = DictSource({'a': 1}) assert config.setdefault('a', 10) == 1 assert config.setdefault('nonexisting', 10) == 10 assert config.nonexisting == 10