From 6ee014725e18bd28af019fc5d8aca0a4e9a47935 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 14 Oct 2005 22:28:38 +0000 Subject: [PATCH] Changed template unit test runner to use new template-loader framework from [870] git-svn-id: http://code.djangoproject.com/svn/django/trunk@871 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/othertests/templates.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index f2da069ea2..d451612713 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -217,15 +217,18 @@ TEMPLATE_TESTS = { '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