diff --git a/module_build_service/config.py b/module_build_service/config.py index e2e2fbe7..34f62e3b 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -350,22 +350,23 @@ class Config(object): raise Exception("Configuration item's name is not allowed: %s" % key) # Create the empty self._key attribute, so we can assign to it. - setattr(self, "_" + key, None) + if not hasattr(self, "_" + key): + setattr(self, "_" + key, None) - # Create self.key property to access the self._key attribute. - # Use the setifok_func if available for the attribute. - setifok_func = '_setifok_{}'.format(key) - if hasattr(self, setifok_func): - setx = lambda self, val: getattr(self, setifok_func)(val) - elif value_type == Path: - # For paths, expanduser. - setx = lambda self, val: setattr( - self, "_" + key, os.path.expanduser(val)) - else: - setx = lambda self, val: setattr(self, "_" + key, val) - getx = lambda self: getattr(self, "_" + key) - delx = lambda self: delattr(self, "_" + key) - setattr(Config, key, property(getx, setx, delx)) + # Create self.key property to access the self._key attribute. + # Use the setifok_func if available for the attribute. + setifok_func = '_setifok_{}'.format(key) + if hasattr(self, setifok_func): + setx = lambda self, val: getattr(self, setifok_func)(val) + elif value_type == Path: + # For paths, expanduser. + setx = lambda self, val: setattr( + self, "_" + key, os.path.expanduser(val)) + else: + setx = lambda self, val: setattr(self, "_" + key, val) + getx = lambda self: getattr(self, "_" + key) + delx = lambda self: delattr(self, "_" + key) + setattr(Config, key, property(getx, setx, delx)) # managed/registered configuration items if key in self._defaults: diff --git a/tests/test_config.py b/tests/test_config.py index 73a24ca7..0787293d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -35,3 +35,7 @@ class TestConfig(unittest.TestCase): test_dir = "~/modulebuild/builds" conf.mock_resultsdir = test_dir self.assertEqual(conf.mock_resultsdir, os.path.expanduser(test_dir)) + + test_dir = "~/modulebuild/builds" + conf.cache_dir = test_dir + self.assertEqual(conf.cache_dir, os.path.expanduser(test_dir))