def test_toArray_config(): config = Config({'life': 'brian', 'spam': {'ham': 'rabbit'}}) assert { 'life': 'brian', 'spam': { 'ham': 'rabbit' } } == config.toArray(), "Config toArray Not Working"
def test_merge_config(): config = Config({'life': 'brian', 'spam': {'ham': 'rabbit'}}) merge = Config({'life': 'meaning', 'spam': {'ham': 'killer', 'new': 'ni'}}) config.merge(merge) assert isinstance(config.spam, Config), "Config merge Not Working" assert { 'life': 'meaning', 'spam': { 'ham': 'killer', 'new': 'ni' } } == config.toArray(), "Config merge Not Working"
def test_itemmethods_config(): config = Config({ 'life': 'brian', 'spam': { 'ham': 'rabbit' } }, allowModifications=True) assert config['life'] == 'brian', "Config __getitem__ Not Working" config['spam']['ham'] = 'eggs' assert config['spam']['ham'] == 'eggs', "Config __setitem__ Not Working" del config['life'] assert { 'spam': { 'ham': 'eggs' } } == config.toArray(), "Config __delitem__ Not Working" config.setReadOnly() with pytest.raises(RuntimeException): config['spam']['ham'] = 'foo' with pytest.raises(InvalidArgumentException): del config['spam']