summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_auth_backends.py
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2017-05-28 21:37:21 +0200
committerTim Graham <timograham@gmail.com>2017-07-29 19:07:23 -0400
commita51c4de1945be2225f20fad794cfb52d8f1f9236 (patch)
tree36386b70a27cf027a8a491de319c3e59e0d3d0cd /tests/auth_tests/test_auth_backends.py
parent38988f289f7f5708f5ea85de2d5dfe0d86b23106 (diff)
Used assertRaisesMessage() to test Django's error messages.
Diffstat (limited to 'tests/auth_tests/test_auth_backends.py')
-rw-r--r--tests/auth_tests/test_auth_backends.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/auth_tests/test_auth_backends.py b/tests/auth_tests/test_auth_backends.py
index ea9ddd426c..744f8ad817 100644
--- a/tests/auth_tests/test_auth_backends.py
+++ b/tests/auth_tests/test_auth_backends.py
@@ -445,7 +445,11 @@ class NoBackendsTest(TestCase):
self.user = User.objects.create_user('test', 'test@example.com', 'test')
def test_raises_exception(self):
- with self.assertRaises(ImproperlyConfigured):
+ msg = (
+ 'No authentication backends have been defined. '
+ 'Does AUTHENTICATION_BACKENDS contain anything?'
+ )
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
self.user.has_perm(('perm', TestObj()))
@@ -626,7 +630,11 @@ class ImproperlyConfiguredUserModelTest(TestCase):
request = HttpRequest()
request.session = self.client.session
- with self.assertRaises(ImproperlyConfigured):
+ msg = (
+ "AUTH_USER_MODEL refers to model 'thismodel.doesntexist' "
+ "that has not been installed"
+ )
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
get_user(request)