changeset 5802:1173317b4f1a

pytest migration: simplify hg+git test class hierarchies No need to use multiple inheritance when single inheritance can do it just as well. Let the git/hg test cases just derive from _BaseTestCase which in turn derives from TestControllerPytest. Also remove empty setup_class/teardown_class methods.
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Fri, 11 Mar 2016 21:43:57 +0100
parents 15c40f8a3510
children 72e8508d9758
files kallithea/tests/functional/test_admin_repos.py kallithea/tests/functional/test_forks.py
diffstat 2 files changed, 13 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/functional/test_admin_repos.py	Tue Apr 26 17:35:13 2016 +0200
+++ b/kallithea/tests/functional/test_admin_repos.py	Fri Mar 11 21:43:57 2016 +0100
@@ -27,7 +27,7 @@
     return perm
 
 
-class _BaseTest(object):
+class _BaseTestCase(TestControllerPytest):
     """
     Write all tests here
     """
@@ -37,14 +37,6 @@
     OTHER_TYPE_REPO = None
     OTHER_TYPE = None
 
-    @classmethod
-    def setup_class(cls):
-        pass
-
-    @classmethod
-    def teardown_class(cls):
-        pass
-
     def test_index(self):
         self.log_user()
         response = self.app.get(url('repos'))
@@ -604,7 +596,7 @@
         # repo must not be in filesystem !
         self.assertFalse(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)))
 
-class TestAdminReposControllerGIT(TestControllerPytest, _BaseTest):
+class TestAdminReposControllerGIT(_BaseTestCase):
     REPO = GIT_REPO
     REPO_TYPE = 'git'
     NEW_REPO = NEW_GIT_REPO
@@ -612,7 +604,7 @@
     OTHER_TYPE = 'hg'
 
 
-class TestAdminReposControllerHG(TestControllerPytest, _BaseTest):
+class TestAdminReposControllerHG(_BaseTestCase):
     REPO = HG_REPO
     REPO_TYPE = 'hg'
     NEW_REPO = NEW_HG_REPO
--- a/kallithea/tests/functional/test_forks.py	Tue Apr 26 17:35:13 2016 +0200
+++ b/kallithea/tests/functional/test_forks.py	Fri Mar 11 21:43:57 2016 +0100
@@ -12,14 +12,14 @@
 
 fixture = Fixture()
 
-class _BaseFixture(object):
-    @classmethod
-    def setup_class(cls):
-        pass
-
-    @classmethod
-    def teardown_class(cls):
-        pass
+class _BaseTestCase(TestControllerPytest):
+    """
+    Write all tests here
+    """
+    REPO = None
+    REPO_TYPE = None
+    NEW_REPO = None
+    REPO_FORK = None
 
     def setup_method(self, method):
         self.username = u'forkuser'
@@ -33,15 +33,6 @@
         Session().commit()
 
 
-class _BaseTestCase(object):
-    """
-    Write all tests here
-    """
-    REPO = None
-    REPO_TYPE = None
-    NEW_REPO = None
-    REPO_FORK = None
-
     def test_index(self):
         self.log_user()
         repo_name = self.REPO
@@ -221,14 +212,14 @@
         response.mustcontain('There are no forks yet')
 
 
-class TestGIT(TestControllerPytest, _BaseTestCase, _BaseFixture):
+class TestGIT(_BaseTestCase):
     REPO = GIT_REPO
     NEW_REPO = NEW_GIT_REPO
     REPO_TYPE = 'git'
     REPO_FORK = GIT_FORK
 
 
-class TestHG(TestControllerPytest, _BaseTestCase, _BaseFixture):
+class TestHG(_BaseTestCase):
     REPO = HG_REPO
     NEW_REPO = NEW_HG_REPO
     REPO_TYPE = 'hg'