From fc4f45ebdccd87f140f39bebed897053c7f345c5 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 4 Feb 2020 21:58:07 +0100 Subject: Used assertRaisesMessage() in various tests. --- tests/template_tests/syntax_tests/test_include.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests/template_tests/syntax_tests/test_include.py') diff --git a/tests/template_tests/syntax_tests/test_include.py b/tests/template_tests/syntax_tests/test_include.py index 8587639674..b840c676f7 100644 --- a/tests/template_tests/syntax_tests/test_include.py +++ b/tests/template_tests/syntax_tests/test_include.py @@ -201,9 +201,8 @@ class IncludeTests(SimpleTestCase): """ engine = Engine(app_dirs=True, debug=True) template = engine.get_template('test_include_error.html') - with self.assertRaises(TemplateDoesNotExist) as e: + with self.assertRaisesMessage(TemplateDoesNotExist, 'missing.html'): template.render(Context()) - self.assertEqual(e.exception.args[0], 'missing.html') def test_extends_include_missing_baseloader(self): """ @@ -213,9 +212,8 @@ class IncludeTests(SimpleTestCase): """ engine = Engine(app_dirs=True, debug=True) template = engine.get_template('test_extends_error.html') - with self.assertRaises(TemplateDoesNotExist) as e: + with self.assertRaisesMessage(TemplateDoesNotExist, 'missing.html'): template.render(Context()) - self.assertEqual(e.exception.args[0], 'missing.html') def test_extends_include_missing_cachedloader(self): engine = Engine(debug=True, loaders=[ @@ -225,15 +223,13 @@ class IncludeTests(SimpleTestCase): ]) template = engine.get_template('test_extends_error.html') - with self.assertRaises(TemplateDoesNotExist) as e: + with self.assertRaisesMessage(TemplateDoesNotExist, 'missing.html'): template.render(Context()) - self.assertEqual(e.exception.args[0], 'missing.html') # Repeat to ensure it still works when loading from the cache template = engine.get_template('test_extends_error.html') - with self.assertRaises(TemplateDoesNotExist) as e: + with self.assertRaisesMessage(TemplateDoesNotExist, 'missing.html'): template.render(Context()) - self.assertEqual(e.exception.args[0], 'missing.html') def test_include_template_argument(self): """ -- cgit v1.3