Commits

Anthony Menasse committed b6534f3

factor out common test setup

Comments (0)

Files changed (1)

current_user/tests/tests.py

 from django.http import HttpResponse
 from django.db.models import signals
 
-class TestCurrentUserMiddleware(TestCase):
+class TestSetup(object):
 
     def setUp(self):
 
         self.factory = RequestFactory()
         (self.user,created) = User.objects.get_or_create(username='davros')
+        signals.pre_save.receivers = []
 
-        signals.pre_save.receivers = []
+
+class TestCurrentUserMiddleware(TestSetup,TestCase):
 
 
     def test_middleware_adds_user_to_objects_current_user_field_on_create(self):
         self.assertNotEqual(receivers[0][1],receivers[1][1])
 
 
-
-class TestCreateUserMiddleware(TestCase):
-
-    def setUp(self):
-
-        self.factory = RequestFactory()
-        (self.user,created) = User.objects.get_or_create(username='davros')
-
-        signals.pre_save.receivers = []
+class TestCreateUserMiddleware(TestSetup,TestCase):
 
 
     def test_middleware_adds_user_to_objects_current_user_field_on_create(self):
         self.assertEquals(example.created_by,self.user)
 
 
-class  TestCombinedMiddleware(TestCase):
-
-    def setUp(self):
-
-        self.factory = RequestFactory()
-        (self.user,created) = User.objects.get_or_create(username='davros')
-
-        signals.pre_save.receivers = []
+class  TestCombinedMiddleware(TestSetup,TestCase):
 
 
     def test_middleware_combined(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.