James Bennett avatar James Bennett committed 141ace5

Clean up a bit in the test suite.

Comments (0)

Files changed (2)

registration/tests/backends.py

     def setUp(self):
         """
         Create an instance of the default backend for use in testing,
-        and set ``ACCOUNT_ACTIVATION_DAYS``.
+        and set ``ACCOUNT_ACTIVATION_DAYS`` if it's not set already.
 
         """
         from registration.backends.default import DefaultBackend
         self.backend = DefaultBackend()
         self.old_activation = getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', None)
-        settings.ACCOUNT_ACTIVATION_DAYS = 7
+        if self.old_activation is None:
+            settings.ACCOUNT_ACTIVATION_DAYS = 7
 
     def tearDown(self):
         """
-        Restore the original value of ``ACCOUNT_ACTIVATION_DAYS``.
+        Yank out ``ACCOUNT_ACTIVATION_DAYS`` back out if it wasn't
+        originally set.
 
         """
-        settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation
+        if self.old_activation is None:
+            settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation
 
     def test_registration(self):
         """

registration/tests/views.py

     Test the registration views.
 
     """
+    # URL patterns here use the default backend since we know it's
+    # available, and set up patterns exercising all the keyword
+    # arguments to the views.
     urls = 'registration.tests.urls'
 
     def setUp(self):
         """
-        Set ``REGISTRATION_BACKEND`` to the default backend, and store
-        the original value to be restored later.
+        Set ``ACCOUNT_ACTIVATION_DAYS`` if it's not already set,
+        because we'll use it to test the activation logic.
 
         """
-        self.old_backend = getattr(settings, 'REGISTRATION_BACKEND', None)
-        settings.REGISTRATION_BACKEND = 'registration.backends.default.DefaultBackend'
         self.old_activation = getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', None)
-        settings.ACCOUNT_ACTIVATION_DAYS = 7
+        if self.old_activation is None:
+            settings.ACCOUNT_ACTIVATION_DAYS = 7
 
     def tearDown(self):
         """
-        Restore the original value of ``REGISTRATION_BACKEND``.
+        Yank ``ACCOUNT_ACTIVATION_DAYS`` back out if it wasn't
+        originally set.
 
         """
-        settings.REGISTRATION_BACKEND = self.old_backend
-        settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation
+        if self.old_activation is None:
+            settings.ACCOUNT_ACTIVATION_DAYS = self.old_activation
 
     def test_registration_view_initial(self):
         """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.