[PATCH 05/25] tests: Clean up 'test_checks'

Stephen Finucane stephen.finucane at intel.com
Fri Jun 24 07:53:26 AEST 2016


* Make use of 'create_' helper
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Include every import on its own line

Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
 patchwork/tests/test_checks.py |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/patchwork/tests/test_checks.py b/patchwork/tests/test_checks.py
index 85c02c1..193cd6b 100644
--- a/patchwork/tests/test_checks.py
+++ b/patchwork/tests/test_checks.py
@@ -22,22 +22,16 @@ from datetime import timedelta
 
 from django.test import TransactionTestCase
 
-from patchwork.models import Patch, Check
-from patchwork.tests.utils import defaults, create_user
+from patchwork.models import Check
+from patchwork.tests.utils import create_patches
+from patchwork.tests.utils import create_user
 
 
 class PatchChecksTest(TransactionTestCase):
     fixtures = ['default_tags', 'default_states']
 
     def setUp(self):
-        project = defaults.project
-        defaults.project.save()
-        defaults.patch_author_person.save()
-        self.patch = Patch(project=project,
-                           msgid='x', name=defaults.patch_name,
-                           submitter=defaults.patch_author_person,
-                           diff='')
-        self.patch.save()
+        self.patch = create_patches()[0]
         self.user = create_user()
 
     def create_check(self, **kwargs):
@@ -87,9 +81,6 @@ class PatchChecksTest(TransactionTestCase):
             if state not in state_counts:
                 self.assertEqual(counts[state], 0)
 
-    def tearDown(self):
-        self.patch.delete()
-
     def test_checks__no_checks(self):
         self.assertChecksEqual(self.patch, [])
 
-- 
1.7.4.1



More information about the Patchwork mailing list