diff options
Diffstat (limited to 'tests/regressiontests/test_client_regress/models.py')
| -rw-r--r-- | tests/regressiontests/test_client_regress/models.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py index 16c26365dd..5d650923a4 100644 --- a/tests/regressiontests/test_client_regress/models.py +++ b/tests/regressiontests/test_client_regress/models.py @@ -5,9 +5,10 @@ import os from django.conf import settings from django.test import Client, TestCase +from django.test.utils import ContextList from django.core.urlresolvers import reverse from django.core.exceptions import SuspiciousOperation -from django.template import TemplateDoesNotExist, TemplateSyntaxError +from django.template import TemplateDoesNotExist, TemplateSyntaxError, Context class AssertContainsTests(TestCase): def test_contains(self): @@ -455,6 +456,26 @@ class zzUrlconfSubstitutionTests(TestCase): url = reverse('arg_view', args=['somename']) self.assertEquals(url, '/test_client_regress/arg_view/somename/') +class ContextTests(TestCase): + fixtures = ['testdata'] + + 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.assertEqual(response.context['get-foo'], 'whiz') + self.assertEqual(response.context['request-foo'], 'whiz') + self.assertEqual(response.context['data'], 'sausage') + + 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'}) + self.assertEqual(response.context.__class__, ContextList) + self.assertEqual(len(response.context), 2) + self.assertEqual(response.context['get-foo'], 'whiz') + self.assertEqual(response.context['request-foo'], 'whiz') + self.assertEqual(response.context['data'], 'bacon') + class SessionTests(TestCase): fixtures = ['testdata.json'] |
