def revert(self): """ Revert any changes made to settings. """ for attr, value in self._changed.items(): setattr(django_settings, attr, value) for attr in self._added: delattr(django_settings, attr) self._changed = {} self._added = [] if self.isolated: self._isolated_overrides = BaseSettings()
def test_import_env_raw(self): storage = BaseSettings() import_env_vars({'WEBLATE_FOO': '(r"/project/(.*)$$",)'}, storage) self.assertEqual(storage.FOO, ('/project/(.*)$',))
def test_import_env_env(self): storage = BaseSettings() import_env_vars({'WEBLATE_FOO': '"$BAR"', 'BAR': 'baz'}, storage) self.assertEqual(storage.FOO, 'baz')
def test_import_env_tuple(self): storage = BaseSettings() import_env_vars({'WEBLATE_FOO': '(1, 2)'}, storage) self.assertEqual(storage.FOO, (1, 2))
def test_import_env_int(self): storage = BaseSettings() import_env_vars({'WEBLATE_FOO': '1234'}, storage) self.assertEqual(storage.FOO, 1234)
def test_import_env_string(self): storage = BaseSettings() import_env_vars({'WEBLATE_FOO': '"bar"'}, storage) self.assertEqual(storage.FOO, 'bar')
def set_isolated(self, value): if value: self._isolated_overrides = BaseSettings() self._isolated = value