changeset 5051:12ae08b2fe3f

tests: avoid executing tests in base classes Fixes lots of failures with pytest by making sure base test classes don't inherit from unittest.TestCase or by prefacing name with an underscore so tests don't get executed by pytest.
author Marc Abramowitz <marc@marc-abramowitz.com>
date Tue, 21 Apr 2015 08:35:36 -0700
parents 5c8c77b7ca56
children 9dd17228c0dc
files kallithea/tests/api/api_base.py kallithea/tests/api/test_api_git.py kallithea/tests/api/test_api_hg.py kallithea/tests/functional/test_admin_repos.py kallithea/tests/functional/test_forks.py kallithea/tests/vcs/base.py kallithea/tests/vcs/test_archives.py kallithea/tests/vcs/test_branches.py kallithea/tests/vcs/test_changesets.py kallithea/tests/vcs/test_getitem.py kallithea/tests/vcs/test_getslice.py kallithea/tests/vcs/test_git.py kallithea/tests/vcs/test_repository.py kallithea/tests/vcs/test_tags.py kallithea/tests/vcs/test_workdirs.py
diffstat 15 files changed, 51 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/api/api_base.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/api/api_base.py	Tue Apr 21 08:35:36 2015 -0700
@@ -88,7 +88,7 @@
     return gr
 
 
-class BaseTestApi(object):
+class _BaseTestApi(object):
     REPO = None
     REPO_TYPE = None
 
--- a/kallithea/tests/api/test_api_git.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/api/test_api_git.py	Tue Apr 21 08:35:36 2015 -0700
@@ -13,9 +13,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from kallithea.tests import *
-from kallithea.tests.api.api_base import BaseTestApi
+from kallithea.tests.api.api_base import _BaseTestApi
 
 
-class TestGitApi(BaseTestApi, TestController):
+class TestGitApi(_BaseTestApi, TestController):
     REPO = GIT_REPO
     REPO_TYPE = 'git'
--- a/kallithea/tests/api/test_api_hg.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/api/test_api_hg.py	Tue Apr 21 08:35:36 2015 -0700
@@ -13,9 +13,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from kallithea.tests import *
-from kallithea.tests.api.api_base import BaseTestApi
+from kallithea.tests.api.api_base import _BaseTestApi
 
 
-class TestHgApi(BaseTestApi, TestController):
+class TestHgApi(_BaseTestApi, TestController):
     REPO = HG_REPO
     REPO_TYPE = 'hg'
--- a/kallithea/tests/functional/test_admin_repos.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/functional/test_admin_repos.py	Tue Apr 21 08:35:36 2015 -0700
@@ -26,7 +26,7 @@
     return perm
 
 
-class _BaseTest(TestController):
+class _BaseTest(object):
     """
     Write all tests here
     """
@@ -638,7 +638,7 @@
         # repo must not be in filesystem !
         self.assertFalse(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)))
 
-class TestAdminReposControllerGIT(_BaseTest):
+class TestAdminReposControllerGIT(TestController, _BaseTest):
     REPO = GIT_REPO
     REPO_TYPE = 'git'
     NEW_REPO = NEW_GIT_REPO
@@ -646,7 +646,7 @@
     OTHER_TYPE = 'hg'
 
 
-class TestAdminReposControllerHG(_BaseTest):
+class TestAdminReposControllerHG(TestController, _BaseTest):
     REPO = HG_REPO
     REPO_TYPE = 'hg'
     NEW_REPO = NEW_HG_REPO
--- a/kallithea/tests/functional/test_forks.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/functional/test_forks.py	Tue Apr 21 08:35:36 2015 -0700
@@ -1,4 +1,7 @@
 # -*- coding: utf-8 -*-
+
+import unittest
+
 from kallithea.tests import *
 from kallithea.tests.fixture import Fixture
 
@@ -12,15 +15,7 @@
 from kallithea.tests import *
 
 
-class _BaseTest(TestController):
-    """
-    Write all tests here
-    """
-    REPO = None
-    REPO_TYPE = None
-    NEW_REPO = None
-    REPO_FORK = None
-
+class _BaseFixture(unittest.TestCase):
     @classmethod
     def setup_class(cls):
         pass
@@ -40,6 +35,16 @@
         Session().delete(self.u1)
         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
@@ -218,14 +223,14 @@
         response.mustcontain('There are no forks yet')
 
 
-class TestGIT(_BaseTest):
+class TestGIT(TestController, _BaseTestCase, _BaseFixture):
     REPO = GIT_REPO
     NEW_REPO = NEW_GIT_REPO
     REPO_TYPE = 'git'
     REPO_FORK = GIT_FORK
 
 
-class TestHG(_BaseTest):
+class TestHG(TestController, _BaseTestCase, _BaseFixture):
     REPO = HG_REPO
     NEW_REPO = NEW_HG_REPO
     REPO_TYPE = 'hg'
--- a/kallithea/tests/vcs/base.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/base.py	Tue Apr 21 08:35:36 2015 -0700
@@ -13,7 +13,7 @@
 from kallithea.lib.vcs.nodes import FileNode
 
 
-class BackendTestMixin(object):
+class _BackendTestMixin(object):
     """
     This is a backend independent test case class which should be created
     with ``type`` method.
@@ -103,7 +103,7 @@
         'backend_alias': alias,
     }
     cls_name = ''.join(('%s base backend test' % alias).title().split())
-    bases = (BackendTestMixin, unittest.TestCase)
+    bases = (_BackendTestMixin, unittest.TestCase)
     globals()[cls_name] = type(cls_name, bases, attrs)
 
 
--- a/kallithea/tests/vcs/test_archives.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_archives.py	Tue Apr 21 08:35:36 2015 -0700
@@ -6,14 +6,14 @@
 import datetime
 import tempfile
 import StringIO
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 from kallithea.lib.vcs.exceptions import VCSError
 from kallithea.lib.vcs.nodes import FileNode
 from kallithea.lib.vcs.utils.compat import unittest
 
 
-class ArchivesTestCaseMixin(BackendTestMixin):
+class ArchivesTestCaseMixin(_BackendTestMixin):
 
     @classmethod
     def _get_commits(cls):
--- a/kallithea/tests/vcs/test_branches.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_branches.py	Tue Apr 21 08:35:36 2015 -0700
@@ -5,11 +5,11 @@
 from kallithea.lib.vcs.utils.compat import unittest
 from kallithea.lib.vcs.nodes import FileNode
 
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 
 
-class BranchesTestCaseMixin(BackendTestMixin):
+class BranchesTestCaseMixin(_BackendTestMixin):
 
     @classmethod
     def _get_commits(cls):
--- a/kallithea/tests/vcs/test_changesets.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_changesets.py	Tue Apr 21 08:35:36 2015 -0700
@@ -4,7 +4,7 @@
 import time
 import datetime
 from kallithea.lib import vcs
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 
 from kallithea.lib.vcs.backends.base import BaseChangeset
@@ -50,7 +50,7 @@
             'removed': [],
         })
 
-class ChangesetsWithCommitsTestCaseixin(BackendTestMixin):
+class _ChangesetsWithCommitsTestCaseixin(_BackendTestMixin):
     recreate_repo_per_test = True
 
     @classmethod
@@ -146,7 +146,7 @@
             self.assertEqual([sha], self.repo.get_changeset(test_rev).children)
 
 
-class ChangesetsTestCaseMixin(BackendTestMixin):
+class _ChangesetsTestCaseMixin(_BackendTestMixin):
     recreate_repo_per_test = False
 
     @classmethod
@@ -301,7 +301,7 @@
             list(self.repo.get_changesets(start=last-1, end=0))
 
 
-class ChangesetsChangesTestCaseMixin(BackendTestMixin):
+class _ChangesetsChangesTestCaseMixin(_BackendTestMixin):
     recreate_repo_per_test = False
 
     @classmethod
@@ -373,17 +373,17 @@
     }
     # tests with additional commits
     cls_name = ''.join(('%s changesets with commits test' % alias).title().split())
-    bases = (ChangesetsWithCommitsTestCaseixin, unittest.TestCase)
+    bases = (_ChangesetsWithCommitsTestCaseixin, unittest.TestCase)
     globals()[cls_name] = type(cls_name, bases, attrs)
 
     # tests without additional commits
     cls_name = ''.join(('%s changesets test' % alias).title().split())
-    bases = (ChangesetsTestCaseMixin, unittest.TestCase)
+    bases = (_ChangesetsTestCaseMixin, unittest.TestCase)
     globals()[cls_name] = type(cls_name, bases, attrs)
 
     # tests changes
     cls_name = ''.join(('%s changesets changes test' % alias).title().split())
-    bases = (ChangesetsChangesTestCaseMixin, unittest.TestCase)
+    bases = (_ChangesetsChangesTestCaseMixin, unittest.TestCase)
     globals()[cls_name] = type(cls_name, bases, attrs)
 
 
--- a/kallithea/tests/vcs/test_getitem.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_getitem.py	Tue Apr 21 08:35:36 2015 -0700
@@ -1,13 +1,13 @@
 from __future__ import with_statement
 
 import datetime
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 from kallithea.lib.vcs.nodes import FileNode
 from kallithea.lib.vcs.utils.compat import unittest
 
 
-class GetitemTestCaseMixin(BackendTestMixin):
+class GetitemTestCaseMixin(_BackendTestMixin):
 
     @classmethod
     def _get_commits(cls):
--- a/kallithea/tests/vcs/test_getslice.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_getslice.py	Tue Apr 21 08:35:36 2015 -0700
@@ -1,13 +1,13 @@
 from __future__ import with_statement
 
 import datetime
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 from kallithea.lib.vcs.nodes import FileNode
 from kallithea.lib.vcs.utils.compat import unittest
 
 
-class GetsliceTestCaseMixin(BackendTestMixin):
+class GetsliceTestCaseMixin(_BackendTestMixin):
 
     @classmethod
     def _get_commits(cls):
--- a/kallithea/tests/vcs/test_git.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_git.py	Tue Apr 21 08:35:36 2015 -0700
@@ -8,7 +8,7 @@
 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
 from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
 from kallithea.lib.vcs.utils.compat import unittest
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, get_new_dir
 
 
@@ -620,7 +620,7 @@
             changeset.added
 
 
-class GitSpecificWithRepoTest(BackendTestMixin, unittest.TestCase):
+class GitSpecificWithRepoTest(_BackendTestMixin, unittest.TestCase):
     backend_alias = 'git'
 
     @classmethod
@@ -688,7 +688,7 @@
             % (3, self.repo._get_revision(0), self.repo._get_revision(1)))
 
 
-class GitRegressionTest(BackendTestMixin, unittest.TestCase):
+class GitRegressionTest(_BackendTestMixin, unittest.TestCase):
     backend_alias = 'git'
 
     @classmethod
--- a/kallithea/tests/vcs/test_repository.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_repository.py	Tue Apr 21 08:35:36 2015 -0700
@@ -1,6 +1,6 @@
 from __future__ import with_statement
 import datetime
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 from kallithea.tests.vcs.conf import TEST_USER_CONFIG_FILE
 from kallithea.lib.vcs.nodes import FileNode
@@ -8,7 +8,7 @@
 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
 
 
-class RepositoryBaseTest(BackendTestMixin):
+class RepositoryBaseTest(_BackendTestMixin):
     recreate_repo_per_test = False
 
     @classmethod
@@ -46,7 +46,7 @@
         self.assertTrue(self.repo != dummy())
 
 
-class RepositoryGetDiffTest(BackendTestMixin):
+class RepositoryGetDiffTest(_BackendTestMixin):
 
     @classmethod
     def _get_commits(cls):
--- a/kallithea/tests/vcs/test_tags.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_tags.py	Tue Apr 21 08:35:36 2015 -0700
@@ -1,13 +1,13 @@
 from __future__ import with_statement
 
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 from kallithea.lib.vcs.exceptions import TagAlreadyExistError
 from kallithea.lib.vcs.exceptions import TagDoesNotExistError
 from kallithea.lib.vcs.utils.compat import unittest
 
 
-class TagsTestCaseMixin(BackendTestMixin):
+class TagsTestCaseMixin(_BackendTestMixin):
 
     def test_new_tag(self):
         tip = self.repo.get_changeset()
--- a/kallithea/tests/vcs/test_workdirs.py	Mon Apr 20 20:38:21 2015 +0200
+++ b/kallithea/tests/vcs/test_workdirs.py	Tue Apr 21 08:35:36 2015 -0700
@@ -3,11 +3,11 @@
 import datetime
 from kallithea.lib.vcs.nodes import FileNode
 from kallithea.lib.vcs.utils.compat import unittest
-from kallithea.tests.vcs.base import BackendTestMixin
+from kallithea.tests.vcs.base import _BackendTestMixin
 from kallithea.tests.vcs.conf import SCM_TESTS
 
 
-class WorkdirTestCaseMixin(BackendTestMixin):
+class WorkdirTestCaseMixin(_BackendTestMixin):
 
     @classmethod
     def _get_commits(cls):