Permalink
Browse files

Support for different template loaders

  • Loading branch information...
1 parent 05b1696 commit 0d79f503d1a712d95e4d12962a72339ed1fedfc2 @gugu gugu committed Sep 24, 2012
View
4 django/contrib/auth/tests/models.py
@@ -18,15 +18,15 @@ def tearDown(self):
otherwise the old value is restored"""
if self.old_AUTH_PROFILE_MODULE is None and \
hasattr(settings, 'AUTH_PROFILE_MODULE'):
- del settings.AUTH_PROFILE_MODULE
+ settings.AUTH_PROFILE_MODULE = None
if self.old_AUTH_PROFILE_MODULE is not None:
settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE
def test_site_profile_not_available(self):
# calling get_profile without AUTH_PROFILE_MODULE set
if hasattr(settings, 'AUTH_PROFILE_MODULE'):
- del settings.AUTH_PROFILE_MODULE
+ settings.AUTH_PROFILE_MODULE = None
user = User.objects.get(username='testclient')
self.assertRaises(SiteProfileNotAvailable, user.get_profile)
View
7 django/contrib/auth/tests/views.py
@@ -11,6 +11,7 @@
from django.http import QueryDict
from django.utils.encoding import force_unicode
from django.utils.html import escape
+from django.template import loader
from django.test import TestCase
from django.test.utils import override_settings
@@ -35,11 +36,17 @@ def setUp(self):
settings.TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
+ self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
+ settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader')
+ loader.template_source_loaders = None #Flushing loader cache
def tearDown(self):
settings.LANGUAGES = self.old_LANGUAGES
settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
+ settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
+ loader.template_source_loaders = None #Flushing loader cache
def login(self, password='password'):
response = self.client.post('/login/', {
View
9 django/contrib/flatpages/tests/csrf.py
@@ -2,6 +2,8 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase, Client
+from django.template import loader
+
class FlatpageCSRFTests(TestCase):
fixtures = ['sample_flatpages']
@@ -23,13 +25,20 @@ def setUp(self):
'templates'
),
)
+ self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
+ settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader')
+ loader.template_source_loaders = None
self.old_LOGIN_URL = settings.LOGIN_URL
settings.LOGIN_URL = '/accounts/login/'
def tearDown(self):
settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
settings.LOGIN_URL = self.old_LOGIN_URL
+ settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
+ loader.template_source_loaders = None
+
def test_view_flatpage(self):
"A flatpage can be served through a view, even when the middleware is in use"
View
14 django/contrib/flatpages/tests/middleware.py
@@ -3,6 +3,8 @@
from django.contrib.auth.models import User
from django.contrib.flatpages.models import FlatPage
from django.test import TestCase
+from django.template import loader
+
class FlatpageMiddlewareTests(TestCase):
fixtures = ['sample_flatpages']
@@ -22,11 +24,17 @@ def setUp(self):
)
self.old_LOGIN_URL = settings.LOGIN_URL
settings.LOGIN_URL = '/accounts/login/'
+ self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
+ settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader')
+ loader.template_source_loaders = None
def tearDown(self):
settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
settings.LOGIN_URL = self.old_LOGIN_URL
+ settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
+ loader.template_source_loaders = None
def test_view_flatpage(self):
"A flatpage can be served through a view, even when the middleware is in use"
@@ -106,12 +114,18 @@ def setUp(self):
settings.LOGIN_URL = '/accounts/login/'
self.old_APPEND_SLASH = settings.APPEND_SLASH
settings.APPEND_SLASH = True
+ self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
+ settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader')
+ loader.template_source_loaders = None
def tearDown(self):
settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
settings.LOGIN_URL = self.old_LOGIN_URL
settings.APPEND_SLASH = self.old_APPEND_SLASH
+ settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
+ loader.template_source_loaders = None
def test_redirect_view_flatpage(self):
"A flatpage can be served through a view and should add a slash"
View
13 django/contrib/flatpages/tests/views.py
@@ -3,6 +3,7 @@
from django.contrib.auth.models import User
from django.contrib.flatpages.models import FlatPage
from django.test import TestCase
+from django.template import loader
class FlatpageViewTests(TestCase):
fixtures = ['sample_flatpages']
@@ -20,13 +21,19 @@ def setUp(self):
'templates'
),
)
+ self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
+ settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader')
+ loader.template_source_loaders = None
self.old_LOGIN_URL = settings.LOGIN_URL
settings.LOGIN_URL = '/accounts/login/'
def tearDown(self):
settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
settings.LOGIN_URL = self.old_LOGIN_URL
+ settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
+ loader.template_source_loaders = None
def test_view_flatpage(self):
"A flatpage can be served through a view"
@@ -95,12 +102,18 @@ def setUp(self):
settings.LOGIN_URL = '/accounts/login/'
self.old_APPEND_SLASH = settings.APPEND_SLASH
settings.APPEND_SLASH = True
+ self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
+ settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader')
+ loader.template_source_loaders = None
def tearDown(self):
settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
settings.LOGIN_URL = self.old_LOGIN_URL
settings.APPEND_SLASH = self.old_APPEND_SLASH
+ settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
+ loader.template_source_loaders = None
def test_redirect_view_flatpage(self):
"A flatpage can be served through a view and should add a slash"

0 comments on commit 0d79f50

Please sign in to comment.