summaryrefslogtreecommitdiff
path: root/tests/regressiontests/context_processors
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2009-10-20 14:14:27 +0000
committerLuke Plant <L.Plant.98@cantab.net>2009-10-20 14:14:27 +0000
commitaaa9ccfe141f772baa8e08a7815f975e1ab29326 (patch)
tree0abce37a5e5c6a1ba0b37398f10154dd3eb6686f /tests/regressiontests/context_processors
parentc1b3808ec0387b831eb255ce0759b47b19c67542 (diff)
[1.1.X] Fixed #12060 - equality tests between User and SimpleLazyObject-wrapped User failed.
Also added more tests for SimpleLazyObject Thanks to ericholscher for report. Backport of r11637 from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11638 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/context_processors')
-rw-r--r--tests/regressiontests/context_processors/tests.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/regressiontests/context_processors/tests.py b/tests/regressiontests/context_processors/tests.py
index 31ecc83ab3..004f90eceb 100644
--- a/tests/regressiontests/context_processors/tests.py
+++ b/tests/regressiontests/context_processors/tests.py
@@ -3,7 +3,7 @@ Tests for Django's bundled context processors.
"""
from django.conf import settings
-from django.contrib.auth.models import Group
+from django.contrib.auth import authenticate
from django.db.models import Q
from django.test import TestCase
from django.template import Template
@@ -74,9 +74,13 @@ class AuthContextProcessorTests(TestCase):
def test_user_attrs(self):
"""
- Test that ContextLazyObject wraps objects properly
+ Test that the lazy objects returned behave just like the wrapped objects.
"""
+ # These are 'functional' level tests for common use cases. Direct
+ # testing of the implementation (SimpleLazyObject) is in the 'utils'
+ # tests.
self.client.login(username='super', password='secret')
+ user = authenticate(username='super', password='secret')
response = self.client.get('/auth_processor_user/')
self.assertContains(response, "unicode: super")
self.assertContains(response, "id: 100")
@@ -100,3 +104,9 @@ class AuthContextProcessorTests(TestCase):
# calling a Python object' in <type 'exceptions.AttributeError'>
# ignored"
query = Q(user=response.context['user']) & Q(someflag=True)
+
+ # Tests for user equality. This is hard because User defines
+ # equality in a non-duck-typing way
+ # See bug #12060
+ self.assertEqual(response.context['user'], user)
+ self.assertEqual(user, response.context['user'])