mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Used assertRaisesMessage() in template_backends tests.
This commit is contained in:
		| @@ -3,20 +3,17 @@ from django.template import engines | |||||||
| from django.test import SimpleTestCase, override_settings | from django.test import SimpleTestCase, override_settings | ||||||
|  |  | ||||||
|  |  | ||||||
| class TemplateStringsTests(SimpleTestCase): | class TemplateUtilsTests(SimpleTestCase): | ||||||
|  |  | ||||||
|     @override_settings(TEMPLATES=[{ |     @override_settings(TEMPLATES=[{'BACKEND': 'raise.import.error'}]) | ||||||
|         'BACKEND': 'raise.import.error', |  | ||||||
|     }]) |  | ||||||
|     def test_backend_import_error(self): |     def test_backend_import_error(self): | ||||||
|         """ |         """ | ||||||
|         Failing to import a backend keeps raising the original import error. |         Failing to import a backend keeps raising the original import error | ||||||
|  |         (#24265). | ||||||
|         Regression test for #24265. |  | ||||||
|         """ |         """ | ||||||
|         with self.assertRaises(ImportError): |         with self.assertRaisesRegex(ImportError, "No module named '?raise"): | ||||||
|             engines.all() |             engines.all() | ||||||
|         with self.assertRaises(ImportError): |         with self.assertRaisesRegex(ImportError, "No module named '?raise"): | ||||||
|             engines.all() |             engines.all() | ||||||
|  |  | ||||||
|     @override_settings(TEMPLATES=[{ |     @override_settings(TEMPLATES=[{ | ||||||
| @@ -27,13 +24,13 @@ class TemplateStringsTests(SimpleTestCase): | |||||||
|     }]) |     }]) | ||||||
|     def test_backend_improperly_configured(self): |     def test_backend_improperly_configured(self): | ||||||
|         """ |         """ | ||||||
|         Failing to initialize a backend keeps raising the original exception. |         Failing to initialize a backend keeps raising the original exception | ||||||
|  |         (#24265). | ||||||
|         Regression test for #24265. |  | ||||||
|         """ |         """ | ||||||
|         with self.assertRaises(ImproperlyConfigured): |         msg = 'app_dirs must not be set when loaders is defined.' | ||||||
|  |         with self.assertRaisesMessage(ImproperlyConfigured, msg): | ||||||
|             engines.all() |             engines.all() | ||||||
|         with self.assertRaises(ImproperlyConfigured): |         with self.assertRaisesMessage(ImproperlyConfigured, msg): | ||||||
|             engines.all() |             engines.all() | ||||||
|  |  | ||||||
|     @override_settings(TEMPLATES=[{ |     @override_settings(TEMPLATES=[{ | ||||||
| @@ -42,5 +39,9 @@ class TemplateStringsTests(SimpleTestCase): | |||||||
|         'BACKEND': 'django.template.backends.django.DjangoTemplates', |         'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||||||
|     }]) |     }]) | ||||||
|     def test_backend_names_must_be_unique(self): |     def test_backend_names_must_be_unique(self): | ||||||
|         with self.assertRaises(ImproperlyConfigured): |         msg = ( | ||||||
|  |             "Template engine aliases aren't unique, duplicates: django. Set " | ||||||
|  |             "a unique NAME for each engine in settings.TEMPLATES." | ||||||
|  |         ) | ||||||
|  |         with self.assertRaisesMessage(ImproperlyConfigured, msg): | ||||||
|             engines.all() |             engines.all() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user