Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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