fixes bug1416703 by implementing a function to do the conversion

Fixes: https://launchpad.net/bugs/1416703
This commit is contained in:
Phill Ridout 2015-02-13 20:41:34 +00:00
parent f6de8a4f7a
commit 126873ddaa
2 changed files with 13 additions and 5 deletions

View File

@ -360,7 +360,7 @@ class Settings(QtCore.QSettings):
:param default_values: A dict with setting keys and their default values.
"""
Settings.__default_settings__ = dict(list(default_values.items()) + list(Settings.__default_settings__.items()))
Settings.__default_settings__.update(default_values)
@staticmethod
def set_filename(ini_file):

View File

@ -123,9 +123,17 @@ class TestSettings(TestCase, TestMixin):
self.assertEqual(str(cm.exception), "'core/does not exists'", 'We should get an exception')
def extend_default_settings_test(self):
with patch.dict(Settings() .__default_settings__, {1: 2, 3: 4}, clear=True):
Settings().extend_default_settings({'a': 'b', 'c': 'd'})
"""
Test that the extend_default_settings method extends the default settings
"""
# GIVEN: A patched __default_settings__ dictionary
with patch.dict(Settings.__default_settings__,
{'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 3}, True):
ds = Settings().__default_settings__
# WHEN: Calling extend_default_settings
Settings.extend_default_settings({'test/setting 3': 4, 'test/extended 1': 1, 'test/extended 2': 2})
self.assertDictEqual(ds, {1: 2, 3: 4, 'a': 'b', 'c': 'd'})
# THEN: The _default_settings__ dictionary_ should have the new keys
self.assertEqual(
Settings.__default_settings__, {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4,
'test/extended 1': 1, 'test/extended 2': 2})