Ticket #4540: django-4540.diff
File django-4540.diff, 2.7 KB (added by , 17 years ago) |
---|
-
django/template/__init__.py
122 122 class TemplateEncodingError(Exception): 123 123 pass 124 124 125 class TemplateContextError(Exception): 126 pass 127 125 128 class VariableDoesNotExist(Exception): 126 129 127 130 def __init__(self, msg, params=()): … … 173 176 174 177 def render(self, context): 175 178 "Display stage -- can be called many times" 179 if (context == None or not isinstance(context,Context)): 180 raise TemplateContextError 176 181 return self.nodelist.render(context) 177 182 178 183 def compile_string(template_string, origin): -
django/test/utils.py
5 5 from django.core.management import call_command 6 6 from django.dispatch import dispatcher 7 7 from django.test import signals 8 from django.template import Template 8 from django.template import Template, Context, TemplateContextError 9 9 from django.utils.translation import deactivate 10 10 11 11 # The prefix to put on the default database name when creating … … 18 18 that can be intercepted by the test system Client 19 19 """ 20 20 dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context) 21 if (context == None or not isinstance(context,Context)): 22 raise TemplateContextError 21 23 return self.nodelist.render(context) 22 24 23 25 class TestSMTPConnection(object): -
tests/regressiontests/templates/tests.py
81 81 return u'ŠĐĆŽćžšđ'.encode('utf-8') 82 82 83 83 class Templates(unittest.TestCase): 84 def test_context_type(self): 85 t = template.Template("{% for val in values %}{{ val }}{% endfor %}") 86 h = {"values": [1, 2, 3], "a":1} 87 c = template.Context(h) 88 # Test1 89 t.original_render(c) 90 t.render(c) 91 # Test2 92 self.assertRaises(template.TemplateContextError, t.original_render, h) 93 self.assertRaises(template.TemplateContextError, t.render, h) 94 # Test4 95 t = template.Template("{{ val }}") 96 self.assertRaises(template.TemplateContextError, t.original_render, None) 97 self.assertRaises(template.TemplateContextError, t.render, None) 98 84 99 def test_loaders_security(self): 85 100 def test_template_sources(path, template_dirs, expected_sources): 86 101 # Fix expected sources so they are normcased and abspathed