summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-02-15 15:42:05 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-02-15 20:47:04 +0100
commit15b711b5ee9ce1ddd01cf88b2bbbec4a6cbec648 (patch)
tree64966e17bf88b41b0f93f04c15ff2e4a76e071be /tests
parent9fbd302f91162434f375b67a533d4a955a439484 (diff)
Deprecated TEMPLATE_DEBUG setting.
Diffstat (limited to 'tests')
-rw-r--r--tests/generic_inline_admin/tests.py10
-rw-r--r--tests/template_tests/test_nodelist.py2
-rw-r--r--tests/template_tests/test_parser.py2
-rw-r--r--tests/template_tests/tests.py55
-rw-r--r--tests/view_tests/tests/test_debug.py3
5 files changed, 44 insertions, 28 deletions
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
index d76e58bf3b..91883e1170 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -15,11 +15,13 @@ from .admin import MediaInline, MediaPermanentInline, site as admin_site
from .models import Category, Episode, EpisodePermanent, Media
-# Set TEMPLATE_DEBUG to True to ensure {% include %} will raise exceptions.
+# Set DEBUG to True to ensure {% include %} will raise exceptions.
# That is how inlines are rendered and #9498 will bubble up if it is an issue.
-@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
- TEMPLATE_DEBUG=True,
- ROOT_URLCONF="generic_inline_admin.urls")
+@override_settings(
+ DEBUG=True,
+ PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
+ ROOT_URLCONF="generic_inline_admin.urls",
+)
class GenericAdminViewTest(TestCase):
fixtures = ['users.xml']
diff --git a/tests/template_tests/test_nodelist.py b/tests/template_tests/test_nodelist.py
index 836d1b6db9..49e09833ed 100644
--- a/tests/template_tests/test_nodelist.py
+++ b/tests/template_tests/test_nodelist.py
@@ -33,7 +33,7 @@ class ErrorIndexTest(TestCase):
Checks whether index of error is calculated correctly in
template debugger in for loops. Refs ticket #5831
"""
- @override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
+ @override_settings(DEBUG=True)
def test_correct_exception_index(self):
tests = [
('{% load bad_tag %}{% for i in range %}{% badsimpletag %}{% endfor %}', (38, 56)),
diff --git a/tests/template_tests/test_parser.py b/tests/template_tests/test_parser.py
index 1e1d76b1bd..5d9a3a374e 100644
--- a/tests/template_tests/test_parser.py
+++ b/tests/template_tests/test_parser.py
@@ -89,7 +89,7 @@ class ParserTests(TestCase):
with six.assertRaisesRegex(self, TypeError, "Variable must be a string or number, got <(class|type) 'dict'>"):
Variable({})
- @override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
+ @override_settings(DEBUG=True)
def test_compile_filter_error(self):
# regression test for #19819
msg = "Could not parse the remainder: '@bar' from 'foo@bar'"
diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py
index ffc3064b41..cf37e1868b 100644
--- a/tests/template_tests/tests.py
+++ b/tests/template_tests/tests.py
@@ -85,10 +85,12 @@ class TemplateLoaderTests(SimpleTestCase):
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR],
+ 'OPTIONS': {
+ # Turn DEBUG on, so that the origin file name will be kept with
+ # the compiled templates.
+ 'debug': True,
+ }
}])
- # Turn TEMPLATE_DEBUG on, so that the origin file name will be kept with
- # the compiled templates.
- @override_settings(TEMPLATE_DEBUG=True)
def test_loader_debug_origin(self):
load_name = 'login.html'
@@ -104,6 +106,7 @@ class TemplateLoaderTests(SimpleTestCase):
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR],
'OPTIONS': {
+ 'debug': True,
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
@@ -111,7 +114,6 @@ class TemplateLoaderTests(SimpleTestCase):
],
},
}])
- @override_settings(TEMPLATE_DEBUG=True)
def test_cached_loader_debug_origin(self):
load_name = 'login.html'
@@ -126,12 +128,12 @@ class TemplateLoaderTests(SimpleTestCase):
self.assertTrue(template_name.endswith(load_name),
'Cached template loaded through cached loader has incorrect name for debug page: %s' % template_name)
- @override_settings(TEMPLATE_DEBUG=True)
+ @override_settings(DEBUG=True)
def test_loader_origin(self):
template = loader.get_template('login.html')
self.assertEqual(template.origin.loadname, 'login.html')
- @override_settings(TEMPLATE_DEBUG=True)
+ @override_settings(DEBUG=True)
def test_string_origin(self):
template = Template('string template')
self.assertEqual(template.origin.source, 'string template')
@@ -140,15 +142,17 @@ class TemplateLoaderTests(SimpleTestCase):
template = loader.get_template('login.html')
self.assertEqual(template.origin, None)
- # TEMPLATE_DEBUG must be true, otherwise the exception raised
- # during {% include %} processing will be suppressed.
- @override_settings(TEMPLATE_DEBUG=True)
# Test the base loader class via the app loader. load_template
# from base is used by all shipped loaders excepting cached,
# which has its own test.
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
+ 'OPTIONS': {
+ # Enable debug, otherwise the exception raised during
+ # {% include %} processing will be suppressed.
+ 'debug': True,
+ }
}])
def test_include_missing_template(self):
"""
@@ -164,15 +168,17 @@ class TemplateLoaderTests(SimpleTestCase):
self.assertEqual(e.args[0], 'missing.html')
self.assertEqual(r, None, 'Template rendering unexpectedly succeeded, produced: ->%r<-' % r)
- # TEMPLATE_DEBUG must be true, otherwise the exception raised
- # during {% include %} processing will be suppressed.
- @override_settings(TEMPLATE_DEBUG=True)
# Test the base loader class via the app loader. load_template
# from base is used by all shipped loaders excepting cached,
# which has its own test.
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
+ 'OPTIONS': {
+ # Enable debug, otherwise the exception raised during
+ # {% include %} processing will be suppressed.
+ 'debug': True,
+ }
}])
def test_extends_include_missing_baseloader(self):
"""
@@ -193,6 +199,7 @@ class TemplateLoaderTests(SimpleTestCase):
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
+ 'debug': True,
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.app_directories.Loader',
@@ -200,7 +207,6 @@ class TemplateLoaderTests(SimpleTestCase):
],
},
}])
- @override_settings(TEMPLATE_DEBUG=True)
def test_extends_include_missing_cachedloader(self):
"""
Same as test_extends_include_missing_baseloader, only tests
@@ -235,19 +241,28 @@ class TemplateLoaderTests(SimpleTestCase):
output = outer_tmpl.render(ctx)
self.assertEqual(output, 'This worked!')
- @override_settings(TEMPLATE_DEBUG=True)
+ @override_settings(TEMPLATES=[{
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'OPTIONS': {
+ 'debug': True,
+ },
+ }])
def test_include_immediate_missing(self):
"""
- Regression test for #16417 -- {% include %} tag raises TemplateDoesNotExist at compile time if TEMPLATE_DEBUG is True
-
Test that an {% include %} tag with a literal string referencing a
template that does not exist does not raise an exception at parse
- time.
+ time. Regression test for #16417.
"""
tmpl = Template('{% include "this_does_not_exist.html" %}')
self.assertIsInstance(tmpl, Template)
- @override_settings(TEMPLATE_DEBUG=True)
+ @override_settings(TEMPLATES=[{
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'debug': True,
+ },
+ }])
def test_include_recursive(self):
comments = [
{
@@ -277,7 +292,7 @@ class TemplateRegressionTests(SimpleTestCase):
split = token.split_contents()
self.assertEqual(split, ["sometag", '_("Page not found")', 'value|yesno:_("yes,no")'])
- @override_settings(SETTINGS_MODULE=None, TEMPLATE_DEBUG=True)
+ @override_settings(SETTINGS_MODULE=None, DEBUG=True)
def test_url_reverse_no_settings_module(self):
# Regression test for #9005
t = Template('{% url will_not_match %}')
@@ -307,7 +322,7 @@ class TemplateRegressionTests(SimpleTestCase):
self.assertGreater(depth, 5,
"The traceback context was lost when reraising the traceback. See #19827")
- @override_settings(DEBUG=True, TEMPLATE_DEBUG=True)
+ @override_settings(DEBUG=True)
def test_no_wrapped_exception(self):
"""
The template system doesn't wrap exceptions, but annotates them.
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 547b96ffc3..a31fb187ee 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -44,8 +44,7 @@ class CallableSettingWrapperTests(TestCase):
self.assertEqual(actual, "repr from the wrapped callable")
-@override_settings(DEBUG=True, TEMPLATE_DEBUG=True,
- ROOT_URLCONF="view_tests.urls")
+@override_settings(DEBUG=True, ROOT_URLCONF="view_tests.urls")
class DebugViewTests(TestCase):
def test_files(self):