Commits

Andrii Kostenko committed 12ea84e Merge

merge

Comments (0)

Files changed (3)

registration/tests/backends.py

 import datetime
+import os
 
 from django.conf import settings
 from django.contrib import admin
 
     """
     backend = DefaultBackend()
-    
+
+    _settings_attributes = {
+        'TEMPLATE_LOADERS': ('django.template.loaders.filesystem.Loader',),
+        'TEMPLATE_DIRS': (os.path.join(os.path.dirname(__file__), 'templates'),),
+        'JINJA2_TEMPLATE_LOADERS': ('django.template.loaders.filesystem.Loader',),
+        'JINJA2_DISABLED_APPS': ('registration', 'debug_toolbar'),
+        'DEBUG_TOOLBAR_CONFIG': {'SHOW_TOOLBAR_CALLBACK': lambda F: False},
+        'LANGUAGES': (('en', 'English'),),
+        'LANGUAGE_CODE': 'en'
+    }
+
     def setUp(self):
         """
         Create an instance of the default backend for use in testing,
 
         """
         self.old_activation = getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', None)
+        for k,v in self._settings_attributes.items():
+            setattr(self, 'old_%s' % k, getattr(settings,k))
+            setattr(settings, k, v)
         if self.old_activation is None:
             settings.ACCOUNT_ACTIVATION_DAYS = 7 # pragma: no cover
 
     def tearDown(self):
         """
-        Yank out ``ACCOUNT_ACTIVATION_DAYS`` back out if it wasn't
+        Yank ``ACCOUNT_ACTIVATION_DAYS`` back out if it wasn't
         originally set.
 
         """
         if self.old_activation is None:
             settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation # pragma: no cover
 
+        for k,v in self._settings_attributes.iteritems():
+            setattr(settings, k, getattr(self,'old_%s' % k))
+
+    
+
     def test_registration(self):
         """
         Test the registration process: registration creates a new

registration/tests/models.py

 import datetime
 import re
+import os
 
 from django.conf import settings
 from django.contrib.auth.models import User
                  'password': 'swordfish',
                  'email': 'alice@example.com'}
     
+    _settings_attributes = {
+        'TEMPLATE_LOADERS': ('django.template.loaders.filesystem.Loader',),
+        'TEMPLATE_DIRS': (os.path.join(os.path.dirname(__file__), 'templates'),),
+        'JINJA2_TEMPLATE_LOADERS': ('django.template.loaders.filesystem.Loader',),
+        'JINJA2_DISABLED_APPS': ('registration', 'debug_toolbar'),
+        'DEBUG_TOOLBAR_CONFIG': {'SHOW_TOOLBAR_CALLBACK': lambda F: False},
+        'LANGUAGES': (('en', 'English'),),
+        'LANGUAGE_CODE': 'en'
+    }
+
     def setUp(self):
+        """
+        Create an instance of the default backend for use in testing,
+        and set ``ACCOUNT_ACTIVATION_DAYS`` if it's not set already.
+
+        """
         self.old_activation = getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', None)
-        settings.ACCOUNT_ACTIVATION_DAYS = 7
+        for k,v in self._settings_attributes.items():
+            setattr(self, 'old_%s' % k, getattr(settings,k))
+            setattr(settings, k, v)
+        if self.old_activation is None:
+            settings.ACCOUNT_ACTIVATION_DAYS = 7 # pragma: no cover
 
     def tearDown(self):
-        settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation
+        """
+        Yank ``ACCOUNT_ACTIVATION_DAYS`` back out if it wasn't
+        originally set.
+
+        """
+        if self.old_activation is None:
+            settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation # pragma: no cover
+
+        for k,v in self._settings_attributes.iteritems():
+            setattr(settings, k, getattr(self,'old_%s' % k))
+
 
     def test_profile_creation(self):
         """

registration/tests/views.py

         for k,v in self._settings_attributes.items():
             setattr(self, 'old_%s' % k, getattr(settings,k))
             setattr(settings, k, v)
-
         if self.old_activation is None:
             settings.ACCOUNT_ACTIVATION_DAYS = 7 # pragma: no cover
         translation.activate('en')