How to use the configupdater.NoSectionError function in ConfigUpdater

To help you get started, we’ve selected a few ConfigUpdater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_get_options(setup_cfg_path):
    updater = ConfigUpdater()
    updater.read(setup_cfg_path)
    options = updater.options('options.packages.find')
    exp_options = ['where', 'exclude']
    assert options == exp_options
    with pytest.raises(NoSectionError):
        updater.options("non_existent_section")
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
updater.read_string(test1_cfg_in)
    updater.set('default', 'key', '1')
    assert updater['default']['key'].value == '1'
    updater.set('default', 'key', 2)
    assert updater['default']['key'].value == 2
    assert str(updater) == test1_cfg_out
    updater.set('default', 'key')
    assert updater['default']['key'].value is None
    assert str(updater) == test1_cfg_out_none
    updater.read_string(test1_cfg_in)
    updater.set('default', 'other_key', 3)
    assert str(updater) == test1_cfg_out_added
    updater.read_string(test1_cfg_in)
    updater['default']['key'].set_values(['param1', 'param2'])
    assert str(updater) == test1_cfg_out_values
    with pytest.raises(NoSectionError):
        updater.set('wrong_section', 'key', '1')