diff --git a/datajoint/settings.py b/datajoint/settings.py index 7977053a3..022ce44b0 100644 --- a/datajoint/settings.py +++ b/datajoint/settings.py @@ -39,6 +39,8 @@ def __getitem__(self, key): return self._conf[key] def __setitem__(self, key, value): + if isinstance(value, collections.Mapping): + raise ValueError("Nested settings are not supported!") if validators[key](value): self._conf[key] = value else: diff --git a/tests/test_settings.py b/tests/test_settings.py index 988c19b3f..9dadcb43a 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -2,21 +2,9 @@ __author__ = 'Fabian Sinz' -from nose.tools import assert_true, assert_raises, assert_equal +from nose.tools import assert_true, assert_raises, assert_equal, raises import datajoint as dj -def nested_dict_compare(d1, d2): - for k, v in d1.items(): - if k not in d2: - return False - else: - if isinstance(v, dict): - tmp = nested_dict_compare(v, d2[k]) - if not tmp: return False - else: - if not v == d2[k]: return False - else: - return True def test_load_save(): old = dj.config['config.file'] @@ -24,9 +12,16 @@ def test_load_save(): dj.config.save() conf = dj.Config() conf.load('tmp.json') - assert_true(nested_dict_compare(conf, dj.config), 'Two config files do not match.') + assert_true(conf == dj.config, 'Two config files do not match.') dj.config['config.file'] = old os.remove('tmp.json') +@raises(ValueError) +def test_nested_check(): + dummy = {'dummy.testval': {'notallowed': 2}} + dj.config.update(dummy) +@raises(ValueError) +def test_nested_check2(): + dj.config['dummy'] = {'dummy2':2}