Fixed #26427 -- Ensured deleted setting doesn't appear in dir(settings)

This commit is contained in:
Claude Paroz 2016-04-23 14:39:15 +02:00
parent 57f76be35e
commit 669c29c8f4
2 changed files with 6 additions and 1 deletions

View File

@ -168,7 +168,10 @@ class UserSettingsHolder(BaseSettings):
super(UserSettingsHolder, self).__delattr__(name)
def __dir__(self):
return list(self.__dict__) + dir(self.default_settings)
return sorted(
s for s in list(self.__dict__) + dir(self.default_settings)
if s not in self._deleted
)
def is_overridden(self, setting):
deleted = (setting in self._deleted)

View File

@ -256,6 +256,8 @@ class SettingsTests(SimpleTestCase):
del settings.USE_L10N
with self.assertRaises(AttributeError):
getattr(settings, 'USE_L10N')
self.assertNotIn('USE_I18N', dir(settings))
self.assertNotIn('USE_L10N', dir(settings))
self.assertEqual(settings.USE_I18N, previous_i18n)
self.assertEqual(settings.USE_L10N, previous_l10n)