Ticket #13334: 13334.diff
File 13334.diff, 4.2 KB (added by , 15 years ago) |
---|
-
django/template/__init__.py
63 63 from django.utils.safestring import SafeData, EscapeData, mark_safe, mark_for_escaping 64 64 from django.utils.formats import localize 65 65 from django.utils.html import escape 66 from django.utils.module_loading import module_has_submodule 66 67 67 68 __all__ = ('Template', 'Context', 'RequestContext', 'compile_string') 68 69 … … 988 989 # an actual import problem with the module. 989 990 app_path, taglib = taglib_module.rsplit('.',1) 990 991 app_module = import_module(app_path) 991 try: 992 imp.find_module(taglib, app_module.__path__) 993 except ImportError,e: 992 if not module_has_submodule(app_module, taglib): 994 993 return None 995 mod = import_module(taglib_module)996 994 try: 995 mod = import_module(taglib_module) 996 except ImportError, e: 997 raise InvalidTemplateLibrary("ImportError raised loading %s: %s" % (taglib_module, e)) 998 try: 997 999 return mod.register 998 1000 except AttributeError: 999 1001 raise InvalidTemplateLibrary("Template library %s does not have a variable named 'register'" % taglib_module) -
tests/regressiontests/templates/tests.py
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: tests\regressiontests\templates\eggs\tagsegg.egg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream
1287 1287 'autoescape-filtertag01': ("{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}", {"first": "<a>"}, template.TemplateSyntaxError), 1288 1288 } 1289 1289 1290 1291 class TemplateTagLoading(unittest.TestCase): 1292 1293 def setUp(self): 1294 self.old_path = sys.path 1295 self.old_apps = settings.INSTALLED_APPS 1296 self.egg_dir = '%s/eggs' % os.path.dirname(__file__) 1297 self.old_tag_modules = template.templatetags_modules 1298 template.templatetags_modules = [] 1299 1300 def tearDown(self): 1301 settings.INSTALLED_APPS = self.old_apps 1302 sys.path = self.old_path 1303 template.templatetags_modules = self.old_tag_modules 1304 1305 def test_load_error(self): 1306 ttext = "{% load broken_tag %}" 1307 self.assertRaises(template.TemplateSyntaxError, template.Template, ttext) 1308 try: 1309 template.Template(ttext) 1310 except template.TemplateSyntaxError, e: 1311 self.assertTrue('ImportError' in e.args[0]) 1312 self.assertTrue('Xtemplate' in e.args[0]) 1313 1314 def test_load_error_egg(self): 1315 ttext = "{% load broken_egg %}" 1316 egg_name = '%s/tagsegg.egg' % self.egg_dir 1317 sys.path.append(egg_name) 1318 settings.INSTALLED_APPS = ('tagsegg',) 1319 self.assertRaises(template.TemplateSyntaxError, template.Template, ttext) 1320 try: 1321 template.Template(ttext) 1322 except template.TemplateSyntaxError, e: 1323 self.assertTrue('ImportError' in e.args[0]) 1324 self.assertTrue('Xtemplate' in e.args[0]) 1325 1326 def test_load_working_egg(self): 1327 ttext = "{% load working_egg %}" 1328 egg_name = '%s/tagsegg.egg' % self.egg_dir 1329 sys.path.append(egg_name) 1330 settings.INSTALLED_APPS = ('tagsegg',) 1331 t = template.Template(ttext) 1332 1290 1333 if __name__ == "__main__": 1291 1334 unittest.main() -
tests/regressiontests/templates/templatetags/broken_tag.py
1 from django import Xtemplate