# HG changeset patch # User Thomas De Schampheleire # Date 1457729037 -3600 # Node ID 1173317b4f1adf4176fed85c21660de28dc8602d # Parent 15c40f8a35100ab4928f3933329b0a97fc996b05 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. diff -r 15c40f8a3510 -r 1173317b4f1a kallithea/tests/functional/test_admin_repos.py --- 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 diff -r 15c40f8a3510 -r 1173317b4f1a kallithea/tests/functional/test_forks.py --- 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'