Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2.

This commit is contained in:
Tim Graham 2017-01-19 21:10:33 -05:00 committed by Aymeric Augustin
parent dc8834cad4
commit 109b33f64c
12 changed files with 43 additions and 42 deletions

View file

@ -313,25 +313,21 @@ class TemplateTagLoadingTests(SimpleTestCase):
msg = (
"Invalid template library specified. ImportError raised when "
"trying to load 'template_tests.broken_tag': cannot import name "
"'?Xtemplate'?"
"'Xtemplate'"
)
with self.assertRaisesRegex(InvalidTemplateLibrary, msg):
Engine(libraries={
'broken_tag': 'template_tests.broken_tag',
})
with self.assertRaisesMessage(InvalidTemplateLibrary, msg):
Engine(libraries={'broken_tag': 'template_tests.broken_tag'})
def test_load_error_egg(self):
egg_name = '%s/tagsegg.egg' % self.egg_dir
msg = (
"Invalid template library specified. ImportError raised when "
"trying to load 'tagsegg.templatetags.broken_egg': cannot "
"import name '?Xtemplate'?"
"import name 'Xtemplate'"
)
with extend_sys_path(egg_name):
with self.assertRaisesRegex(InvalidTemplateLibrary, msg):
Engine(libraries={
'broken_egg': 'tagsegg.templatetags.broken_egg',
})
with self.assertRaisesMessage(InvalidTemplateLibrary, msg):
Engine(libraries={'broken_egg': 'tagsegg.templatetags.broken_egg'})
def test_load_working_egg(self):
ttext = "{% load working_egg %}"