summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Beaven <smileychris@gmail.com>2011-04-22 21:05:29 +0000
committerChris Beaven <smileychris@gmail.com>2011-04-22 21:05:29 +0000
commit9269b606ba96d68c3b6be843539bfa6f443c72dc (patch)
treea8a549d002a631e2485bba7849dcccbbf5f59c6f /tests
parent5977193c018c1aff38cc3f8139798b027742550a (diff)
[1.3.X] Fixes regression #15721 -- {% include %} and RequestContext not working together. Refs #15814.
Backport of r16031, plus the utility from r16030. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16089 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/templates/tests.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 10c7a37258..074852c1c3 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -17,6 +17,8 @@ from django.template import base as template_base
from django.core import urlresolvers
from django.template import loader
from django.template.loaders import app_directories, filesystem, cached
+from django.test.utils import setup_test_template_loader,\
+ restore_template_loaders
from django.utils import unittest
from django.utils.translation import activate, deactivate, ugettext as _
from django.utils.safestring import mark_safe
@@ -1640,5 +1642,34 @@ class TemplateTagLoading(unittest.TestCase):
settings.INSTALLED_APPS = ('tagsegg',)
t = template.Template(ttext)
+
+class RequestContextTests(BaseTemplateResponseTest):
+
+ def setUp(self):
+ templates = {
+ 'child': Template('{{ var|default:"none" }}'),
+ }
+ setup_test_template_loader(templates)
+ self.fake_request = RequestFactory().get('/')
+
+ def tearDown(self):
+ restore_template_loaders()
+
+ def test_include_only(self):
+ """
+ Regression test for #15721, ``{% include %}`` and ``RequestContext``
+ not playing together nicely.
+ """
+ ctx = RequestContext(self.fake_request, {'var': 'parent'})
+ self.assertEqual(
+ template.Template('{% include "child" %}').render(ctx),
+ 'parent'
+ )
+ self.assertEqual(
+ template.Template('{% include "child" only %}').render(ctx),
+ 'none'
+ )
+
+
if __name__ == "__main__":
unittest.main()