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):