Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed template unit test runner to use new template-loader framewor…

…k from [870]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@871 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6ee014725e18bd28af019fc5d8aca0a4e9a47935 1 parent 7aefff7
@adrianholovaty adrianholovaty authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 tests/othertests/templates.py
View
9 tests/othertests/templates.py
@@ -217,15 +217,18 @@ def method(self):
'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError),
}
-# This replaces the standard template loader.
def test_template_loader(template_name, template_dirs=None):
+ "A custom template loader that loads the unit-test templates."
try:
return TEMPLATE_TESTS[template_name][0]
except KeyError:
raise template.TemplateDoesNotExist, template_name
def run_tests(verbosity=0, standalone=False):
- loader.load_template_source, old_template_loader = test_template_loader, loader.load_template_source
+ # Register our custom template loader.
+ old_template_loaders = loader.template_source_loaders
+ loader.template_source_loaders = [test_template_loader]
+
failed_tests = []
tests = TEMPLATE_TESTS.items()
tests.sort()
@@ -248,7 +251,7 @@ def run_tests(verbosity=0, standalone=False):
if verbosity:
print "Template test: %s -- FAILED. Expected %r, got %r" % (name, vals[2], output)
failed_tests.append(name)
- loader.load_template_source = old_template_loader
+ loader.template_source_loaders = old_template_loaders
if failed_tests and not standalone:
msg = "Template tests %s failed." % failed_tests
Please sign in to comment.
Something went wrong with that request. Please try again.