Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Support for different template loaders

  • Loading branch information...
commit 0d79f503d1a712d95e4d12962a72339ed1fedfc2 1 parent 05b1696
Andrii Kostenko authored September 24, 2012
4  django/contrib/auth/tests/models.py
@@ -18,7 +18,7 @@ def tearDown(self):
18 18
         otherwise the old value is restored"""
19 19
         if self.old_AUTH_PROFILE_MODULE is None and \
20 20
                 hasattr(settings, 'AUTH_PROFILE_MODULE'):
21  
-            del settings.AUTH_PROFILE_MODULE
  21
+            settings.AUTH_PROFILE_MODULE = None
22 22
 
23 23
         if self.old_AUTH_PROFILE_MODULE is not None:
24 24
             settings.AUTH_PROFILE_MODULE = self.old_AUTH_PROFILE_MODULE
@@ -26,7 +26,7 @@ def tearDown(self):
26 26
     def test_site_profile_not_available(self):
27 27
         # calling get_profile without AUTH_PROFILE_MODULE set
28 28
         if hasattr(settings, 'AUTH_PROFILE_MODULE'):
29  
-            del settings.AUTH_PROFILE_MODULE
  29
+            settings.AUTH_PROFILE_MODULE = None
30 30
         user = User.objects.get(username='testclient')
31 31
         self.assertRaises(SiteProfileNotAvailable, user.get_profile)
32 32
 
7  django/contrib/auth/tests/views.py
@@ -11,6 +11,7 @@
11 11
 from django.http import QueryDict
12 12
 from django.utils.encoding import force_unicode
13 13
 from django.utils.html import escape
  14
+from django.template import loader
14 15
 from django.test import TestCase
15 16
 from django.test.utils import override_settings
16 17
 
@@ -35,11 +36,17 @@ def setUp(self):
35 36
         settings.TEMPLATE_DIRS = (
36 37
             os.path.join(os.path.dirname(__file__), 'templates'),
37 38
         )
  39
+        self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
  40
+        settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
  41
+                                     'django.template.loaders.app_directories.Loader')
  42
+        loader.template_source_loaders = None #Flushing loader cache
38 43
 
39 44
     def tearDown(self):
40 45
         settings.LANGUAGES = self.old_LANGUAGES
41 46
         settings.LANGUAGE_CODE = self.old_LANGUAGE_CODE
42 47
         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
  48
+        settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
  49
+        loader.template_source_loaders = None #Flushing loader cache
43 50
 
44 51
     def login(self, password='password'):
45 52
         response = self.client.post('/login/', {
9  django/contrib/flatpages/tests/csrf.py
@@ -2,6 +2,8 @@
2 2
 from django.conf import settings
3 3
 from django.contrib.auth.models import User
4 4
 from django.test import TestCase, Client
  5
+from django.template import loader
  6
+
5 7
 
6 8
 class FlatpageCSRFTests(TestCase):
7 9
     fixtures = ['sample_flatpages']
@@ -23,6 +25,10 @@ def setUp(self):
23 25
                 'templates'
24 26
             ),
25 27
         )
  28
+        self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
  29
+        settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
  30
+                                     'django.template.loaders.app_directories.Loader')
  31
+        loader.template_source_loaders = None
26 32
         self.old_LOGIN_URL = settings.LOGIN_URL
27 33
         settings.LOGIN_URL = '/accounts/login/'
28 34
 
@@ -30,6 +36,9 @@ def tearDown(self):
30 36
         settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
31 37
         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
32 38
         settings.LOGIN_URL = self.old_LOGIN_URL
  39
+        settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
  40
+        loader.template_source_loaders = None
  41
+
33 42
 
34 43
     def test_view_flatpage(self):
35 44
         "A flatpage can be served through a view, even when the middleware is in use"
14  django/contrib/flatpages/tests/middleware.py
@@ -3,6 +3,8 @@
3 3
 from django.contrib.auth.models import User
4 4
 from django.contrib.flatpages.models import FlatPage
5 5
 from django.test import TestCase
  6
+from django.template import loader
  7
+
6 8
 
7 9
 class FlatpageMiddlewareTests(TestCase):
8 10
     fixtures = ['sample_flatpages']
@@ -22,11 +24,17 @@ def setUp(self):
22 24
         )
23 25
         self.old_LOGIN_URL = settings.LOGIN_URL
24 26
         settings.LOGIN_URL = '/accounts/login/'
  27
+        self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
  28
+        settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
  29
+                                     'django.template.loaders.app_directories.Loader')
  30
+        loader.template_source_loaders = None
25 31
 
26 32
     def tearDown(self):
27 33
         settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
28 34
         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
29 35
         settings.LOGIN_URL = self.old_LOGIN_URL
  36
+        settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
  37
+        loader.template_source_loaders = None
30 38
 
31 39
     def test_view_flatpage(self):
32 40
         "A flatpage can be served through a view, even when the middleware is in use"
@@ -106,12 +114,18 @@ def setUp(self):
106 114
         settings.LOGIN_URL = '/accounts/login/'
107 115
         self.old_APPEND_SLASH = settings.APPEND_SLASH
108 116
         settings.APPEND_SLASH = True
  117
+        self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
  118
+        settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
  119
+                                     'django.template.loaders.app_directories.Loader')
  120
+        loader.template_source_loaders = None
109 121
 
110 122
     def tearDown(self):
111 123
         settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
112 124
         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
113 125
         settings.LOGIN_URL = self.old_LOGIN_URL
114 126
         settings.APPEND_SLASH = self.old_APPEND_SLASH
  127
+        settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
  128
+        loader.template_source_loaders = None
115 129
 
116 130
     def test_redirect_view_flatpage(self):
117 131
         "A flatpage can be served through a view and should add a slash"
13  django/contrib/flatpages/tests/views.py
@@ -3,6 +3,7 @@
3 3
 from django.contrib.auth.models import User
4 4
 from django.contrib.flatpages.models import FlatPage
5 5
 from django.test import TestCase
  6
+from django.template import loader
6 7
 
7 8
 class FlatpageViewTests(TestCase):
8 9
     fixtures = ['sample_flatpages']
@@ -20,6 +21,10 @@ def setUp(self):
20 21
                 'templates'
21 22
             ),
22 23
         )
  24
+        self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
  25
+        settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
  26
+                                     'django.template.loaders.app_directories.Loader')
  27
+        loader.template_source_loaders = None
23 28
         self.old_LOGIN_URL = settings.LOGIN_URL
24 29
         settings.LOGIN_URL = '/accounts/login/'
25 30
 
@@ -27,6 +32,8 @@ def tearDown(self):
27 32
         settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
28 33
         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
29 34
         settings.LOGIN_URL = self.old_LOGIN_URL
  35
+        settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
  36
+        loader.template_source_loaders = None
30 37
 
31 38
     def test_view_flatpage(self):
32 39
         "A flatpage can be served through a view"
@@ -95,12 +102,18 @@ def setUp(self):
95 102
         settings.LOGIN_URL = '/accounts/login/'
96 103
         self.old_APPEND_SLASH = settings.APPEND_SLASH
97 104
         settings.APPEND_SLASH = True
  105
+        self.old_TEMPLATE_LOADERS = settings.TEMPLATE_LOADERS
  106
+        settings.TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
  107
+                                     'django.template.loaders.app_directories.Loader')
  108
+        loader.template_source_loaders = None
98 109
 
99 110
     def tearDown(self):
100 111
         settings.MIDDLEWARE_CLASSES = self.old_MIDDLEWARE_CLASSES
101 112
         settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
102 113
         settings.LOGIN_URL = self.old_LOGIN_URL
103 114
         settings.APPEND_SLASH = self.old_APPEND_SLASH
  115
+        settings.TEMPLATE_LOADERS = self.old_TEMPLATE_LOADERS
  116
+        loader.template_source_loaders = None
104 117
 
105 118
     def test_redirect_view_flatpage(self):
106 119
         "A flatpage can be served through a view and should add a slash"

0 notes on commit 0d79f50

Please sign in to comment.
Something went wrong with that request. Please try again.