How to use ConfigUpdater - 10 common examples

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_iter_section(setup_cfg_path):
    updater = ConfigUpdater()
    updater.read(setup_cfg_path)
    # we test ne number of blocks, not sections
    assert len([block for block in updater]) == 14
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_add_before_after_section():
    updater = ConfigUpdater()
    updater.read_string(test6_cfg_in)
    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_set_optionxform():
    updater = ConfigUpdater()
    updater.read_string(test13_cfg_in)
    assert updater['section']['capital'].value == '1'
    assert callable(updater.optionxform)
    updater.optionxform = lambda x: x
    updater.read_string(test13_cfg_in)
    assert updater['section']['CAPITAL'].value == '1'
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_iter_option(setup_cfg_path):
    updater = ConfigUpdater()
    updater.read(setup_cfg_path)
    section = updater['metadata']
    # we test ne number of entries, not options
    assert len([entry for entry in section]) == 12
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_constructor(setup_cfg_path):
    updater = ConfigUpdater(delimiters=(':', '='))
    updater.read(setup_cfg_path)
    updater = ConfigUpdater(delimiters=(':', '='), allow_no_value=True)
    updater.read(setup_cfg_path)
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_no_value():
    updater = ConfigUpdater(allow_no_value=True)
    updater.read_string(test11_no_values)
    assert updater['section']['key'].value is None
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_contains_options(setup_cfg_path):
    updater = ConfigUpdater()
    updater.read(setup_cfg_path)
    section = updater['metadata']
    assert 'author' in section
    assert 'wrong_option' not in section
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_del_section():
    updater = ConfigUpdater()
    updater.read_string(test2_cfg_in)
    del updater['section2']
    assert str(updater) == test2_cfg_out
    with pytest.raises(KeyError):
        del updater['section2']
    with pytest.raises(ValueError):
        updater['section1']._get_option_idx('wrong key')
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_len_section(setup_cfg_path):
    updater = ConfigUpdater()
    updater.read(setup_cfg_path)
    section = updater['metadata']
    # we test ne number of entries, not options
    assert len(section) == 12
github pyscaffold / configupdater / tests / test_configupdater.py View on Github external
def test_len_updater(setup_cfg_path):
    updater = ConfigUpdater()
    updater.read(setup_cfg_path)
    # we test the number of blocks, not sections
    assert len(updater) == 14