diff options
Diffstat (limited to 'tests/test_utils')
| -rw-r--r-- | tests/test_utils/tests.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index f8eda7ed39..b1c35d1f80 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -362,22 +362,26 @@ class AssertTemplateUsedContextManagerTests(SimpleTestCase): pass def test_error_message(self): - with self.assertRaisesRegex(AssertionError, r'^template_used/base\.html'): + msg = 'template_used/base.html was not rendered. No template was rendered.' + with self.assertRaisesMessage(AssertionError, msg): with self.assertTemplateUsed('template_used/base.html'): pass - with self.assertRaisesRegex(AssertionError, r'^template_used/base\.html'): + with self.assertRaisesMessage(AssertionError, msg): with self.assertTemplateUsed(template_name='template_used/base.html'): pass - with self.assertRaisesRegex(AssertionError, r'^template_used/base\.html.*template_used/alternative\.html$'): + msg2 = ( + 'template_used/base.html was not rendered. Following templates ' + 'were rendered: template_used/alternative.html' + ) + with self.assertRaisesMessage(AssertionError, msg2): with self.assertTemplateUsed('template_used/base.html'): render_to_string('template_used/alternative.html') - with self.assertRaises(AssertionError) as cm: + with self.assertRaisesMessage(AssertionError, 'No templates used to render the response'): response = self.client.get('/test_utils/no_template_used/') self.assertTemplateUsed(response, 'template_used/base.html') - self.assertEqual(cm.exception.args[0], "No templates used to render the response") def test_failure(self): with self.assertRaises(TypeError): |
