How to use the configupdater.configupdater.DuplicateSectionError 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
with pytest.raises(ValueError):
        updater['section2']['key1'].add_before.section('section1')
    updater['section2'].add_before.section('section1')
    updater['section1']['key1'] = 42
    updater['section2'].add_after.space(1).section('section3')
    assert str(updater) == test6_cfg_out
    with pytest.raises(ValueError):
        updater['section2'].add_before.section(updater['section2']['key1'])
    updater.read_string(test6_cfg_in)
    sect_updater = ConfigUpdater()
    sect_updater.read_string(test6_cfg_in)
    section = sect_updater['section0']
    section.name = 'new_section'
    updater['section2'].add_after.section(section)
    assert str(updater) == test6_cfg_out_new_sect
    with pytest.raises(DuplicateSectionError):
        updater['section2'].add_after.section(section)
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_no_duplicate_blocks_with_blockbuilder():
    updater = ConfigUpdater()
    updater.read_string(test19_cfg_in)
    with pytest.raises(DuplicateOptionError):
        updater['section']['Key0'].add_after.option('key0', '1')
    with pytest.raises(DuplicateSectionError):
        updater['section'].add_after.section('section')
    assert str(updater) == test19_cfg_in