- # Register our custom template loader. Shamelessly cribbed from django core regressiontests.
- 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] , "test:%s" % template_name)
- except KeyError:
- raise template.TemplateDoesNotExist, template_name
-
- cache_loader = cached.Loader(('test_template_loader',))
- cache_loader._cached_loaders = (test_template_loader,)
+ # Register our custom template loader. Shamelessly cribbed from django/tests/regressiontests/templates/tests.py:384.
+ cache_loader = setup_test_template_loader(
+ dict([(name, t[0]) for name, t in template_tests.iteritems()]),
+ use_cached_loader=True,
+ )