Ticket #10130: 10130-r11594.diff
File 10130-r11594.diff, 1.6 KB (added by , 15 years ago) |
---|
-
django/utils/functional.py
281 281 self._setup() 282 282 setattr(self._wrapped, name, value) 283 283 284 def __delattr__(self, name): 285 if name == "_wrapped": 286 raise AttributeError("Wrapped settings object cannot be deleted.") 287 else: 288 if self._wrapped is None: 289 self._setup() 290 delattr(self._wrapped, name) 291 284 292 def _setup(self): 285 293 """ 286 294 Must be implemented by subclasses to initialise the wrapped object. -
tests/regressiontests/settings/tests.py
1 import unittest 2 from django.conf import settings 3 4 class SettingsTest(unittest.TestCase): 5 6 def test_set_delete(self): 7 settings.TEST = 'test' 8 self.assertEqual('test', settings.TEST) 9 del settings.TEST 10 self.assertRaises(AttributeError, lambda: settings.TEST) 11 12 def test_delete_wrapped(self): 13 def del_wrapped(): 14 del settings._wrapped 15 self.assertRaises(AttributeError, del_wrapped)