Author: russellm
Date: 2011-08-22 17:32:35 -0700 (Mon, 22 Aug 2011)
New Revision: 16650
Modified:
django/trunk/django/test/utils.py
django/trunk/tests/regressiontests/settings_tests/tests.py
Log:
Fixed #16672 -- Ensure that test classes decorated with @override_setings gets
the right name when running the tests. Thanks to Julien Phalip for the report
and initial patch
Modified: django/trunk/django/test/utils.py
===================================================================
--- django/trunk/django/test/utils.py 2011-08-22 08:06:52 UTC (rev 16649)
+++ django/trunk/django/test/utils.py 2011-08-23 00:32:35 UTC (rev 16650)
@@ -196,13 +196,22 @@
def __call__(self, test_func):
from django.test import TransactionTestCase
if isinstance(test_func, type) and issubclass(test_func,
TransactionTestCase):
- class inner(test_func):
- def _pre_setup(innerself):
- self.enable()
- super(inner, innerself)._pre_setup()
- def _post_teardown(innerself):
- super(inner, innerself)._post_teardown()
- self.disable()
+ # When decorating a class, we need to construct a new class
+ # with the same name so that the test discovery tools can
+ # get a useful name.
+ def _pre_setup(innerself):
+ self.enable()
+ test_func._pre_setup(innerself)
+ def _post_teardown(innerself):
+ test_func._post_teardown(innerself)
+ self.disable()
+ inner = type(
+ test_func.__name__,
+ (test_func,),
+ {
+ '_pre_setup': _pre_setup,
+ '_post_teardown': _post_teardown,
+ })
else:
@wraps(test_func)
def inner(*args, **kwargs):
Modified: django/trunk/tests/regressiontests/settings_tests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/settings_tests/tests.py 2011-08-22
08:06:52 UTC (rev 16649)
+++ django/trunk/tests/regressiontests/settings_tests/tests.py 2011-08-23
00:32:35 UTC (rev 16650)
@@ -15,6 +15,9 @@
def test_method_override(self):
self.assertEqual(settings.TEST, 'override2')
+ def test_decorated_testcase_name(self):
+ self.assertEquals(FullyDecoratedTranTestCase.__name__,
'FullyDecoratedTranTestCase')
+
FullyDecoratedTranTestCase =
override_settings(TEST='override')(FullyDecoratedTranTestCase)
# @override_settings(TEST='override')
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.