def test_config_save_delete_default_section(config_default): conf = config.get_config() first_section = next(iter(default_config.keys())) config.config_save(conf) conf = ConfigParser() conf.read(user_config_path) assert first_section not in conf.sections()
def test_config_save(config_default): """ Testing configuration saving. Should not save non-default values""" conf = config.get_config() first_section = next(iter(default_config.keys())) first_option = next(iter(default_config[first_section].keys())) conf['new_section'] = {'new_option': 'new_value'} conf[first_section]['non_default_option'] = 'testing' config.config_save(conf) conf = ConfigParser() conf.read(user_config_path) assert 'new_section' in conf.sections() assert 'new_option' in conf['new_section'] assert first_option not in conf[first_section].keys() # not saving default values assert 'non_default_option' in conf[first_section].keys() assert conf[first_section]['non_default_option'] == 'testing'
def test_get_config(config_default): # user_config_path should be nonexistent and stay nonexistent assert not os.path.isfile(user_config_path) config.get_config() assert not os.path.isfile(user_config_path)