Refs #21230 -- removed direct settings manipulation from template tests
This commit is contained in:
parent
2080bce695
commit
2688462f91
|
@ -544,7 +544,11 @@ class TemplateRegressionTests(TestCase):
|
||||||
t.render(Context({}))
|
t.render(Context({}))
|
||||||
|
|
||||||
|
|
||||||
@override_settings(MEDIA_URL="/media/", STATIC_URL="/static/")
|
# Set ALLOWED_INCLUDE_ROOTS so that ssi works.
|
||||||
|
@override_settings(MEDIA_URL="/media/", STATIC_URL="/static/",
|
||||||
|
TEMPLATE_DEBUG=False, ALLOWED_INCLUDE_ROOTS=(
|
||||||
|
os.path.dirname(os.path.abspath(upath(__file__))),),
|
||||||
|
)
|
||||||
class TemplateTests(TransRealMixin, TestCase):
|
class TemplateTests(TransRealMixin, TestCase):
|
||||||
def test_templates(self):
|
def test_templates(self):
|
||||||
template_tests = self.get_template_tests()
|
template_tests = self.get_template_tests()
|
||||||
|
@ -565,19 +569,9 @@ class TemplateTests(TransRealMixin, TestCase):
|
||||||
failures = []
|
failures = []
|
||||||
tests = sorted(template_tests.items())
|
tests = sorted(template_tests.items())
|
||||||
|
|
||||||
# Turn TEMPLATE_DEBUG off, because tests assume that.
|
|
||||||
old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
|
|
||||||
|
|
||||||
# Set TEMPLATE_STRING_IF_INVALID to a known string.
|
# Set TEMPLATE_STRING_IF_INVALID to a known string.
|
||||||
old_invalid = settings.TEMPLATE_STRING_IF_INVALID
|
|
||||||
expected_invalid_str = 'INVALID'
|
expected_invalid_str = 'INVALID'
|
||||||
|
|
||||||
# Set ALLOWED_INCLUDE_ROOTS so that ssi works.
|
|
||||||
old_allowed_include_roots = settings.ALLOWED_INCLUDE_ROOTS
|
|
||||||
settings.ALLOWED_INCLUDE_ROOTS = (
|
|
||||||
os.path.dirname(os.path.abspath(upath(__file__))),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Warm the URL reversing cache. This ensures we don't pay the cost
|
# Warm the URL reversing cache. This ensures we don't pay the cost
|
||||||
# warming the cache during one of the tests.
|
# warming the cache during one of the tests.
|
||||||
urlresolvers.reverse('template_tests.views.client_action',
|
urlresolvers.reverse('template_tests.views.client_action',
|
||||||
|
@ -613,8 +607,8 @@ class TemplateTests(TransRealMixin, TestCase):
|
||||||
(expected_invalid_str, False, invalid_string_result),
|
(expected_invalid_str, False, invalid_string_result),
|
||||||
('', True, template_debug_result)
|
('', True, template_debug_result)
|
||||||
]:
|
]:
|
||||||
settings.TEMPLATE_STRING_IF_INVALID = invalid_str
|
with override_settings(TEMPLATE_STRING_IF_INVALID=invalid_str,
|
||||||
settings.TEMPLATE_DEBUG = template_debug
|
TEMPLATE_DEBUG=template_debug):
|
||||||
for is_cached in (False, True):
|
for is_cached in (False, True):
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
@ -651,9 +645,6 @@ class TemplateTests(TransRealMixin, TestCase):
|
||||||
|
|
||||||
restore_template_loaders()
|
restore_template_loaders()
|
||||||
deactivate()
|
deactivate()
|
||||||
settings.TEMPLATE_DEBUG = old_td
|
|
||||||
settings.TEMPLATE_STRING_IF_INVALID = old_invalid
|
|
||||||
settings.ALLOWED_INCLUDE_ROOTS = old_allowed_include_roots
|
|
||||||
|
|
||||||
self.assertEqual(failures, [], "Tests failed:\n%s\n%s" %
|
self.assertEqual(failures, [], "Tests failed:\n%s\n%s" %
|
||||||
('-' * 70, ("\n%s\n" % ('-' * 70)).join(failures)))
|
('-' * 70, ("\n%s\n" % ('-' * 70)).join(failures)))
|
||||||
|
|
Loading…
Reference in New Issue