summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-01-22 15:31:14 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-01-22 15:31:14 +0000
commitf114fbecc2a486df7fc65f7de1b635520ef1d5ba (patch)
treebd5ba3d3289844867fdf387dcf6b9b027fad4643 /tests
parent7ca9d9306c5e5e175668af513725a16ba3b26d9d (diff)
Fixed #12659 -- Return a more meaningful KeyError message when ContextList lookups fail. Thanks to rodriguealcazar for the suggestion.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12274 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/test_client_regress/models.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py
index 42b763ca41..f3585268b3 100644
--- a/tests/regressiontests/test_client_regress/models.py
+++ b/tests/regressiontests/test_client_regress/models.py
@@ -602,6 +602,12 @@ class ContextTests(TestCase):
self.assertEqual(response.context['request-foo'], 'whiz')
self.assertEqual(response.context['data'], 'sausage')
+ try:
+ response.context['does-not-exist']
+ self.fail('Should not be able to retrieve non-existent key')
+ except KeyError, e:
+ self.assertEquals(e.message, 'does-not-exist')
+
def test_inherited_context(self):
"Context variables can be retrieved from a list of contexts"
response = self.client.get("/test_client_regress/request_data_extended/", data={'foo':'whiz'})
@@ -611,6 +617,13 @@ class ContextTests(TestCase):
self.assertEqual(response.context['request-foo'], 'whiz')
self.assertEqual(response.context['data'], 'bacon')
+ try:
+ response.context['does-not-exist']
+ self.fail('Should not be able to retrieve non-existent key')
+ except KeyError, e:
+ self.assertEquals(e.message, 'does-not-exist')
+
+
class SessionTests(TestCase):
fixtures = ['testdata.json']