Switch tests to new TEMPLATES setting
This commit is contained in:
		@@ -34,12 +34,25 @@ STATIC_URL = '/static/'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
STATIC_ROOT = os.path.join(TEST_DIR, 'static')
 | 
					STATIC_ROOT = os.path.join(TEST_DIR, 'static')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEMPLATE_DIRS = (
 | 
					TEMPLATES = [{
 | 
				
			||||||
 | 
					    'BACKEND': 'django.template.backends.django.DjangoTemplates',
 | 
				
			||||||
 | 
					    'APP_DIRS': True,
 | 
				
			||||||
 | 
					    'DIRS': [
 | 
				
			||||||
        # Specifically choose a name that will not be considered
 | 
					        # Specifically choose a name that will not be considered
 | 
				
			||||||
        # by app_directories loader, to make sure each test uses
 | 
					        # by app_directories loader, to make sure each test uses
 | 
				
			||||||
        # a specific template without considering the others.
 | 
					        # a specific template without considering the others.
 | 
				
			||||||
        os.path.join(TEST_DIR, 'test_templates'),
 | 
					        os.path.join(TEST_DIR, 'test_templates'),
 | 
				
			||||||
)
 | 
					    ],
 | 
				
			||||||
 | 
					}, {
 | 
				
			||||||
 | 
					    'BACKEND': 'django.template.backends.jinja2.Jinja2',
 | 
				
			||||||
 | 
					    'APP_DIRS': True,
 | 
				
			||||||
 | 
					    'DIRS': [
 | 
				
			||||||
 | 
					        # Specifically choose a name that will not be considered
 | 
				
			||||||
 | 
					        # by app_directories loader, to make sure each test uses
 | 
				
			||||||
 | 
					        # a specific template without considering the others.
 | 
				
			||||||
 | 
					        os.path.join(TEST_DIR, 'test_templates_jinja2'),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					}]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SECRET_KEY = "iufoj=mibkpdz*%bob952x(%49rqgv8gg45k36kjcg76&-y5=!"
 | 
					SECRET_KEY = "iufoj=mibkpdz*%bob952x(%49rqgv8gg45k36kjcg76&-y5=!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
from __future__ import with_statement, unicode_literals
 | 
					from __future__ import with_statement, unicode_literals
 | 
				
			||||||
 | 
					import copy
 | 
				
			||||||
import io
 | 
					import io
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
@@ -63,13 +64,20 @@ class OfflineTestCaseMixin(object):
 | 
				
			|||||||
        # Specify both Jinja2 and Django template locations. When the wrong
 | 
					        # Specify both Jinja2 and Django template locations. When the wrong
 | 
				
			||||||
        # engine is used to parse a template, the TemplateSyntaxError will
 | 
					        # engine is used to parse a template, the TemplateSyntaxError will
 | 
				
			||||||
        # cause the template to be skipped over.
 | 
					        # cause the template to be skipped over.
 | 
				
			||||||
 | 
					        # We've hardcoded TEMPLATES[0] to be Django templates backend and
 | 
				
			||||||
 | 
					        # TEMPLATES[1] to be Jinja2 templates backend in test_settings.
 | 
				
			||||||
 | 
					        TEMPLATES = copy.deepcopy(settings.TEMPLATES)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        django_template_dir = os.path.join(
 | 
					        django_template_dir = os.path.join(
 | 
				
			||||||
            settings.TEST_DIR, 'test_templates', self.templates_dir)
 | 
					            TEMPLATES[0]['DIRS'][0], self.templates_dir)
 | 
				
			||||||
        jinja2_template_dir = os.path.join(
 | 
					        jinja2_template_dir = os.path.join(
 | 
				
			||||||
            settings.TEST_DIR, 'test_templates_jinja2', self.templates_dir)
 | 
					            TEMPLATES[1]['DIRS'][0], self.templates_dir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        TEMPLATES[0]['DIRS'] = [django_template_dir]
 | 
				
			||||||
 | 
					        TEMPLATES[1]['DIRS'] = [jinja2_template_dir]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        override_settings = {
 | 
					        override_settings = {
 | 
				
			||||||
            'TEMPLATE_DIRS': (django_template_dir, jinja2_template_dir,),
 | 
					            'TEMPLATES': TEMPLATES,
 | 
				
			||||||
            'COMPRESS_ENABLED': True,
 | 
					            'COMPRESS_ENABLED': True,
 | 
				
			||||||
            'COMPRESS_OFFLINE': True
 | 
					            'COMPRESS_OFFLINE': True
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -164,7 +172,7 @@ class OfflineTestCaseMixin(object):
 | 
				
			|||||||
        import jinja2
 | 
					        import jinja2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        loader = jinja2.FileSystemLoader(
 | 
					        loader = jinja2.FileSystemLoader(
 | 
				
			||||||
            settings.TEMPLATE_DIRS, encoding=settings.FILE_CHARSET)
 | 
					            settings.TEMPLATES[1]['DIRS'], encoding=settings.FILE_CHARSET)
 | 
				
			||||||
        return loader
 | 
					        return loader
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -545,7 +553,7 @@ class OfflineCompressBlockSuperBaseCompressed(OfflineTestCaseMixin, TestCase):
 | 
				
			|||||||
        self.templates = []
 | 
					        self.templates = []
 | 
				
			||||||
        for template_name in self.template_names:
 | 
					        for template_name in self.template_names:
 | 
				
			||||||
            template_path = os.path.join(
 | 
					            template_path = os.path.join(
 | 
				
			||||||
                settings.TEMPLATE_DIRS[0], template_name)
 | 
					                settings.TEMPLATES[0]['DIRS'][0], template_name)
 | 
				
			||||||
            self.template_paths.append(template_path)
 | 
					            self.template_paths.append(template_path)
 | 
				
			||||||
            with io.open(template_path,
 | 
					            with io.open(template_path,
 | 
				
			||||||
                         encoding=settings.FILE_CHARSET) as file_:
 | 
					                         encoding=settings.FILE_CHARSET) as file_:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user