deprecated-setting moval should delete old setting

This commit is contained in:
Matthias 2022-03-08 06:59:30 +01:00
parent 5d4386f037
commit 420cc5c595
2 changed files with 5 additions and 1 deletions

View File

@ -64,6 +64,7 @@ def process_deprecated_setting(config: Dict[str, Any],
section_new_config = config.get(section_new, {}) if section_new else config
section_new_config[name_new] = section_old_config[name_old]
del section_old_config[name_old]
def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None:

View File

@ -1280,11 +1280,14 @@ def test_process_deprecated_setting(mocker, default_conf, caplog):
# The value of the new setting shall have been set to the
# value of the deprecated one
assert default_conf['sectionA']['new_setting'] == 'valB'
# Old setting is removed
assert 'deprecated_setting' not in default_conf['sectionB']
caplog.clear()
# Delete new setting (deprecated exists)
del default_conf['sectionA']['new_setting']
default_conf['sectionB']['deprecated_setting'] = 'valB'
process_deprecated_setting(default_conf,
'sectionB', 'deprecated_setting',
'sectionA', 'new_setting')
@ -1298,7 +1301,7 @@ def test_process_deprecated_setting(mocker, default_conf, caplog):
# Assign new setting
default_conf['sectionA']['new_setting'] = 'valA'
# Delete deprecated setting
del default_conf['sectionB']['deprecated_setting']
default_conf['sectionB'].pop('deprecated_setting', None)
process_deprecated_setting(default_conf,
'sectionB', 'deprecated_setting',
'sectionA', 'new_setting')