Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.2.X] Fixed #13092 -- Added support for the "in" operator when deal…

…ing with context lists. Thanks to clelland for the patch.

Backport of [13510] from trunk.  Backported in order to support some other
tests which need to be backported.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13986 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c7ce5b8929b6dea9e1d0776fdb2bc37686ef9b6b 1 parent cb00181
@spookylukey spookylukey authored
View
6 django/test/utils.py
@@ -36,6 +36,12 @@ def __getitem__(self, key):
else:
return super(ContextList, self).__getitem__(key)
+ def __contains__(self, key):
+ try:
+ value = self[key]
+ except KeyError:
+ return False
+ return True
def instrumented_test_render(self, context):
"""
View
2  tests/regressiontests/test_client_regress/models.py
@@ -620,6 +620,7 @@ def test_single_context(self):
"Context variables can be retrieved from a single context"
response = self.client.get("/test_client_regress/request_data/", data={'foo':'whiz'})
self.assertEqual(response.context.__class__, Context)
+ self.assertTrue('get-foo' in response.context)
self.assertEqual(response.context['get-foo'], 'whiz')
self.assertEqual(response.context['request-foo'], 'whiz')
self.assertEqual(response.context['data'], 'sausage')
@@ -635,6 +636,7 @@ def test_inherited_context(self):
response = self.client.get("/test_client_regress/request_data_extended/", data={'foo':'whiz'})
self.assertEqual(response.context.__class__, ContextList)
self.assertEqual(len(response.context), 2)
+ self.assertTrue('get-foo' in response.context)
self.assertEqual(response.context['get-foo'], 'whiz')
self.assertEqual(response.context['request-foo'], 'whiz')
self.assertEqual(response.context['data'], 'bacon')
Please sign in to comment.
Something went wrong with that request. Please try again.