diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-17 22:10:57 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-28 17:02:30 +0100 |
| commit | cf0fd65ed42d5d4f0585da413db4b1cf7c6b0d1a (patch) | |
| tree | 3f4f652525adf16178018e4ce0c7eddeb0f61360 /tests/view_tests | |
| parent | d3a982556d655adcf4ba331d2def685d8249170f (diff) | |
Deprecated TEMPLATE_LOADERS.
Diffstat (limited to 'tests/view_tests')
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 31 | ||||
| -rw-r--r-- | tests/view_tests/tests/test_defaults.py | 25 |
2 files changed, 34 insertions, 22 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index b9987c72b0..ab04c6622d 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -63,21 +63,28 @@ class DebugViewTests(TestCase): response = self.client.get('/raises400/') self.assertContains(response, '<div class="context" id="', status_code=400) + # Ensure no 403.html template exists to test the default case. + @override_settings(TEMPLATES=[{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + }]) def test_403(self): - # Ensure no 403.html template exists to test the default case. - with override_settings(TEMPLATE_LOADERS=[]): - response = self.client.get('/raises403/') - self.assertContains(response, '<h1>403 Forbidden</h1>', status_code=403) + response = self.client.get('/raises403/') + self.assertContains(response, '<h1>403 Forbidden</h1>', status_code=403) + # Set up a test 403.html template. + @override_settings(TEMPLATES=[{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'OPTIONS': { + 'loaders': [ + ('django.template.loaders.locmem.Loader', { + '403.html': 'This is a test template for a 403 error.', + }), + ], + }, + }]) def test_403_template(self): - # Set up a test 403.html template. - with override_settings(TEMPLATE_LOADERS=[ - ('django.template.loaders.locmem.Loader', { - '403.html': 'This is a test template for a 403 Forbidden error.', - }) - ]): - response = self.client.get('/raises403/') - self.assertContains(response, 'test template', status_code=403) + response = self.client.get('/raises403/') + self.assertContains(response, 'test template', status_code=403) def test_404(self): response = self.client.get('/raises404/') diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py index 6a3a495c23..7b95211a5a 100644 --- a/tests/view_tests/tests/test_defaults.py +++ b/tests/view_tests/tests/test_defaults.py @@ -35,21 +35,26 @@ class DefaultsTests(TestCase): response = self.client.get('/server_error/') self.assertEqual(response.status_code, 500) + @override_settings(TEMPLATES=[{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'OPTIONS': { + 'loaders': [ + ('django.template.loaders.locmem.Loader', { + '404.html': 'This is a test template for a 404 error.', + '500.html': 'This is a test template for a 500 error.', + }), + ], + }, + }]) def test_custom_templates(self): """ Test that 404.html and 500.html templates are picked by their respective handler. """ - with override_settings(TEMPLATE_LOADERS=[ - ('django.template.loaders.locmem.Loader', { - '404.html': 'This is a test template for a 404 error.', - '500.html': 'This is a test template for a 500 error.', - }), - ]): - for code, url in ((404, '/non_existing_url/'), (500, '/server_error/')): - response = self.client.get(url) - self.assertContains(response, "test template for a %d error" % code, - status_code=code) + for code, url in ((404, '/non_existing_url/'), (500, '/server_error/')): + response = self.client.get(url) + self.assertContains(response, "test template for a %d error" % code, + status_code=code) def test_get_absolute_url_attributes(self): "A model can set attributes on the get_absolute_url method" |
