aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_request.py
diff options
context:
space:
mode:
authorTom Christie2015-02-09 20:43:50 +0000
committerTom Christie2015-02-09 20:43:50 +0000
commitfbb21caaaa01033bbd34b0c63ab48243ffb6310e (patch)
tree5d0fdee18c9bf02733b1df913c4cddd9e3e86da7 /tests/test_request.py
parent407480b4840990ff17f9a33b293cfcf15bb6f7c5 (diff)
parent7b639c0cd0676172cc8502e833f5b708f39f9a83 (diff)
downloaddjango-rest-framework-fbb21caaaa01033bbd34b0c63ab48243ffb6310e.tar.bz2
Merge master
Diffstat (limited to 'tests/test_request.py')
-rw-r--r--tests/test_request.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_request.py b/tests/test_request.py
index 02a9b1e2..c274ab69 100644
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -249,9 +249,29 @@ class TestUserSetter(TestCase):
login(self.request, self.user)
self.assertEqual(self.wrapped_request.user, self.user)
+ def test_calling_user_fails_when_attribute_error_is_raised(self):
+ """
+ This proves that when an AttributeError is raised inside of the request.user
+ property, that we can handle this and report the true, underlying error.
+ """
+ class AuthRaisesAttributeError(object):
+ def authenticate(self, request):
+ import rest_framework
+ rest_framework.MISSPELLED_NAME_THAT_DOESNT_EXIST
-class TestAuthSetter(TestCase):
+ self.request = Request(factory.get('/'), authenticators=(AuthRaisesAttributeError(),))
+ SessionMiddleware().process_request(self.request)
+ login(self.request, self.user)
+ try:
+ self.request.user
+ except AttributeError as error:
+ self.assertEqual(str(error), "'module' object has no attribute 'MISSPELLED_NAME_THAT_DOESNT_EXIST'")
+ else:
+ assert False, 'AttributeError not raised'
+
+
+class TestAuthSetter(TestCase):
def test_auth_can_be_set(self):
request = Request(factory.get('/'))
request.auth = 'DUMMY'