summaryrefslogtreecommitdiff
path: root/tests/test_utils
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-19 21:10:33 -0500
committerAymeric Augustin <aymeric.augustin@m4x.org>2017-01-20 08:49:47 +0100
commit109b33f64c8d3f48c9e0bd3ea8d42fe6f3cb02b7 (patch)
treece4c2311d5993e2e6b70062530834269314c0eb1 /tests/test_utils
parentdc8834cad41aa407f402dc54788df3cd37ab3e22 (diff)
Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2.
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/tests.py14
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):