diff options
| author | Nick Martini <nmartini@orcasinc.com> | 2012-09-07 13:31:01 -0400 |
|---|---|---|
| committer | Nick Martini <nmartini@orcasinc.com> | 2012-09-07 13:31:01 -0400 |
| commit | 9e190e1c82a287c88636f8fffea125224526f0e5 (patch) | |
| tree | f4bf6f9ef87d43de90c3a8d095cab9ba151ddb68 /django | |
| parent | 9ce58906af4a5f5a0739598ac10103fef3642419 (diff) | |
| parent | 292322f977b1844e15ba25d59d1e985461571c15 (diff) | |
Merge branch 'master' of git://github.com/django/django
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/tests/models.py | 11 | ||||
| -rw-r--r-- | django/test/testcases.py | 2 | ||||
| -rw-r--r-- | django/utils/six.py | 7 |
3 files changed, 14 insertions, 6 deletions
diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/models.py index b40157bfe2..e4efee4339 100644 --- a/django/contrib/auth/tests/models.py +++ b/django/contrib/auth/tests/models.py @@ -1,8 +1,9 @@ from django.conf import settings +from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable, + UserManager) from django.test import TestCase from django.test.utils import override_settings -from django.contrib.auth.models import (Group, User, - SiteProfileNotAvailable, UserManager) +from django.utils import six @override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='') @@ -13,19 +14,19 @@ class ProfileTestCase(TestCase): # calling get_profile without AUTH_PROFILE_MODULE set del settings.AUTH_PROFILE_MODULE - with self.assertRaisesRegexp(SiteProfileNotAvailable, + with six.assertRaisesRegex(self, SiteProfileNotAvailable, "You need to set AUTH_PROFILE_MODULE in your project"): user.get_profile() # Bad syntax in AUTH_PROFILE_MODULE: settings.AUTH_PROFILE_MODULE = 'foobar' - with self.assertRaisesRegexp(SiteProfileNotAvailable, + with six.assertRaisesRegex(self, SiteProfileNotAvailable, "app_label and model_name should be separated by a dot"): user.get_profile() # module that doesn't exist settings.AUTH_PROFILE_MODULE = 'foo.bar' - with self.assertRaisesRegexp(SiteProfileNotAvailable, + with six.assertRaisesRegex(self, SiteProfileNotAvailable, "Unable to load the profile model"): user.get_profile() diff --git a/django/test/testcases.py b/django/test/testcases.py index f12c431d3a..3c681db329 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -358,7 +358,7 @@ class SimpleTestCase(ut2.TestCase): args: Extra args. kwargs: Extra kwargs. """ - return self.assertRaisesRegexp(expected_exception, + return six.assertRaisesRegex(self, expected_exception, re.escape(expected_message), callable_obj, *args, **kwargs) def assertFieldOutput(self, fieldclass, valid, invalid, field_args=None, diff --git a/django/utils/six.py b/django/utils/six.py index e4ce939844..9e3823128f 100644 --- a/django/utils/six.py +++ b/django/utils/six.py @@ -370,13 +370,20 @@ def with_metaclass(meta, base=object): if PY3: _iterlists = "lists" + _assertRaisesRegex = "assertRaisesRegex" else: _iterlists = "iterlists" + _assertRaisesRegex = "assertRaisesRegexp" + def iterlists(d): """Return an iterator over the values of a MultiValueDict.""" return getattr(d, _iterlists)() +def assertRaisesRegex(self, *args, **kwargs): + return getattr(self, _assertRaisesRegex)(*args, **kwargs) + + add_move(MovedModule("_dummy_thread", "dummy_thread")) add_move(MovedModule("_thread", "thread")) |
