Changeset - 1173317b4f1a
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 10 years ago 2016-03-11 21:43:57
thomas.de.schampheleire@gmail.com
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.
2 files changed with 13 insertions and 30 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_admin_repos.py
Show inline comments
 
@@ -27,7 +27,7 @@ def _get_permission_for_user(user, repo)
 
    return perm
 

	
 

	
 
class _BaseTest(object):
 
class _BaseTestCase(TestControllerPytest):
 
    """
 
    Write all tests here
 
    """
 
@@ -37,14 +37,6 @@ class _BaseTest(object):
 
    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 @@ class _BaseTest(object):
 
        # 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 @@ class TestAdminReposControllerGIT(TestCo
 
    OTHER_TYPE = 'hg'
 

	
 

	
 
class TestAdminReposControllerHG(TestControllerPytest, _BaseTest):
 
class TestAdminReposControllerHG(_BaseTestCase):
 
    REPO = HG_REPO
 
    REPO_TYPE = 'hg'
 
    NEW_REPO = NEW_HG_REPO
kallithea/tests/functional/test_forks.py
Show inline comments
 
@@ -12,14 +12,14 @@ from kallithea.model.meta import Session
 

	
 
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 @@ class _BaseFixture(object):
 
        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 @@ class _BaseTestCase(object):
 
        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'
0 comments (0 inline, 0 general)