diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/models.py
index 5d0e4f1..b08de72 100644
a
|
b
|
from django.contrib.auth.models import (Group, User,
|
6 | 6 | |
7 | 7 | |
8 | 8 | class ProfileTestCase(TestCase): |
9 | | fixtures = ['authtestdata.json'] |
10 | 9 | |
11 | 10 | def setUp(self): |
12 | 11 | """Backs up the AUTH_PROFILE_MODULE""" |
13 | | self.old_AUTH_PROFILE_MODULE = getattr(settings, |
14 | | 'AUTH_PROFILE_MODULE', None) |
15 | | |
16 | | def tearDown(self): |
17 | | """Restores the AUTH_PROFILE_MODULE -- if it was not set it is deleted, |
18 | | otherwise the old value is restored""" |
19 | | if self.old_AUTH_PROFILE_MODULE is None and \ |
20 | | hasattr(settings, 'AUTH_PROFILE_MODULE'): |
21 | | del settings.AUTH_PROFILE_MODULE |
22 | | |
23 | | if self.old_AUTH_PROFILE_MODULE is not None: |
24 | | settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE |
| 12 | self.user = User.objects.create(username='testclient') |
25 | 13 | |
| 14 | @override_settings(AUTH_PROFILE_MODULE='') |
26 | 15 | def test_site_profile_not_available(self): |
27 | 16 | # calling get_profile without AUTH_PROFILE_MODULE set |
28 | | if hasattr(settings, 'AUTH_PROFILE_MODULE'): |
29 | | del settings.AUTH_PROFILE_MODULE |
30 | | user = User.objects.get(username='testclient') |
31 | | self.assertRaises(SiteProfileNotAvailable, user.get_profile) |
| 17 | self.assertRaises(SiteProfileNotAvailable, self.user.get_profile) |
32 | 18 | |
| 19 | @override_settings(AUTH_PROFILE_MODULE='foobar') |
| 20 | def test_site_profile_bad_syntax(self): |
33 | 21 | # Bad syntax in AUTH_PROFILE_MODULE: |
34 | | settings.AUTH_PROFILE_MODULE = 'foobar' |
35 | | self.assertRaises(SiteProfileNotAvailable, user.get_profile) |
| 22 | self.assertRaises(SiteProfileNotAvailable, self.user.get_profile) |
36 | 23 | |
| 24 | @override_settings(AUTH_PROFILE_MODULE='foo.bar') |
| 25 | def test_site_profile_missing_module(self): |
37 | 26 | # module that doesn't exist |
38 | | settings.AUTH_PROFILE_MODULE = 'foo.bar' |
39 | | self.assertRaises(SiteProfileNotAvailable, user.get_profile) |
| 27 | self.assertRaises(SiteProfileNotAvailable, self.user.get_profile) |
40 | 28 | |
41 | 29 | ProfileTestCase = override_settings(USE_TZ=False)(ProfileTestCase) |
42 | 30 | |