mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #17011 - Made override_settings modify a decorated class in-place rather than creating a dynamic subclass, so as to avoid infinite recursion when used with super(). Thanks jsdalton for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16942 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -35,6 +35,38 @@ class FullyDecoratedTestCase(TestCase):
|
||||
|
||||
FullyDecoratedTestCase = override_settings(TEST='override')(FullyDecoratedTestCase)
|
||||
|
||||
|
||||
class ClassDecoratedTestCaseSuper(TestCase):
|
||||
"""
|
||||
Dummy class for testing max recursion error in child class call to
|
||||
super(). Refs #17011.
|
||||
|
||||
"""
|
||||
def test_max_recursion_error(self):
|
||||
pass
|
||||
|
||||
|
||||
@override_settings(TEST='override')
|
||||
class ClassDecoratedTestCase(ClassDecoratedTestCaseSuper):
|
||||
def test_override(self):
|
||||
self.assertEqual(settings.TEST, 'override')
|
||||
|
||||
@override_settings(TEST='override2')
|
||||
def test_method_override(self):
|
||||
self.assertEqual(settings.TEST, 'override2')
|
||||
|
||||
def test_max_recursion_error(self):
|
||||
"""
|
||||
Overriding a method on a super class and then calling that method on
|
||||
the super class should not trigger infinite recursion. See #17011.
|
||||
|
||||
"""
|
||||
try:
|
||||
super(ClassDecoratedTestCase, self).test_max_recursion_error()
|
||||
except RuntimeError, e:
|
||||
self.fail()
|
||||
|
||||
|
||||
class SettingGetter(object):
|
||||
def __init__(self):
|
||||
self.test = getattr(settings, 'TEST', 'undefined')
|
||||
|
||||
Reference in New Issue
Block a user