##// END OF EJS Templates
tests: avoid executing tests in base classes...
Marc Abramowitz -
r5051:12ae08b2 default
parent child Browse files
Show More
@@ -88,7 +88,7 b' def make_repo_group(name=TEST_REPO_GROUP'
88 return gr
88 return gr
89
89
90
90
91 class BaseTestApi(object):
91 class _BaseTestApi(object):
92 REPO = None
92 REPO = None
93 REPO_TYPE = None
93 REPO_TYPE = None
94
94
@@ -13,9 +13,9 b''
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 from kallithea.tests import *
15 from kallithea.tests import *
16 from kallithea.tests.api.api_base import BaseTestApi
16 from kallithea.tests.api.api_base import _BaseTestApi
17
17
18
18
19 class TestGitApi(BaseTestApi, TestController):
19 class TestGitApi(_BaseTestApi, TestController):
20 REPO = GIT_REPO
20 REPO = GIT_REPO
21 REPO_TYPE = 'git'
21 REPO_TYPE = 'git'
@@ -13,9 +13,9 b''
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 from kallithea.tests import *
15 from kallithea.tests import *
16 from kallithea.tests.api.api_base import BaseTestApi
16 from kallithea.tests.api.api_base import _BaseTestApi
17
17
18
18
19 class TestHgApi(BaseTestApi, TestController):
19 class TestHgApi(_BaseTestApi, TestController):
20 REPO = HG_REPO
20 REPO = HG_REPO
21 REPO_TYPE = 'hg'
21 REPO_TYPE = 'hg'
@@ -26,7 +26,7 b' def _get_permission_for_user(user, repo)'
26 return perm
26 return perm
27
27
28
28
29 class _BaseTest(TestController):
29 class _BaseTest(object):
30 """
30 """
31 Write all tests here
31 Write all tests here
32 """
32 """
@@ -638,7 +638,7 b' class _BaseTest(TestController):'
638 # repo must not be in filesystem !
638 # repo must not be in filesystem !
639 self.assertFalse(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)))
639 self.assertFalse(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)))
640
640
641 class TestAdminReposControllerGIT(_BaseTest):
641 class TestAdminReposControllerGIT(TestController, _BaseTest):
642 REPO = GIT_REPO
642 REPO = GIT_REPO
643 REPO_TYPE = 'git'
643 REPO_TYPE = 'git'
644 NEW_REPO = NEW_GIT_REPO
644 NEW_REPO = NEW_GIT_REPO
@@ -646,7 +646,7 b' class TestAdminReposControllerGIT(_BaseT'
646 OTHER_TYPE = 'hg'
646 OTHER_TYPE = 'hg'
647
647
648
648
649 class TestAdminReposControllerHG(_BaseTest):
649 class TestAdminReposControllerHG(TestController, _BaseTest):
650 REPO = HG_REPO
650 REPO = HG_REPO
651 REPO_TYPE = 'hg'
651 REPO_TYPE = 'hg'
652 NEW_REPO = NEW_HG_REPO
652 NEW_REPO = NEW_HG_REPO
@@ -1,4 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
3 import unittest
4
2 from kallithea.tests import *
5 from kallithea.tests import *
3 from kallithea.tests.fixture import Fixture
6 from kallithea.tests.fixture import Fixture
4
7
@@ -12,15 +15,7 b' fixture = Fixture()'
12 from kallithea.tests import *
15 from kallithea.tests import *
13
16
14
17
15 class _BaseTest(TestController):
18 class _BaseFixture(unittest.TestCase):
16 """
17 Write all tests here
18 """
19 REPO = None
20 REPO_TYPE = None
21 NEW_REPO = None
22 REPO_FORK = None
23
24 @classmethod
19 @classmethod
25 def setup_class(cls):
20 def setup_class(cls):
26 pass
21 pass
@@ -40,6 +35,16 b' class _BaseTest(TestController):'
40 Session().delete(self.u1)
35 Session().delete(self.u1)
41 Session().commit()
36 Session().commit()
42
37
38
39 class _BaseTestCase(object):
40 """
41 Write all tests here
42 """
43 REPO = None
44 REPO_TYPE = None
45 NEW_REPO = None
46 REPO_FORK = None
47
43 def test_index(self):
48 def test_index(self):
44 self.log_user()
49 self.log_user()
45 repo_name = self.REPO
50 repo_name = self.REPO
@@ -218,14 +223,14 b' class _BaseTest(TestController):'
218 response.mustcontain('There are no forks yet')
223 response.mustcontain('There are no forks yet')
219
224
220
225
221 class TestGIT(_BaseTest):
226 class TestGIT(TestController, _BaseTestCase, _BaseFixture):
222 REPO = GIT_REPO
227 REPO = GIT_REPO
223 NEW_REPO = NEW_GIT_REPO
228 NEW_REPO = NEW_GIT_REPO
224 REPO_TYPE = 'git'
229 REPO_TYPE = 'git'
225 REPO_FORK = GIT_FORK
230 REPO_FORK = GIT_FORK
226
231
227
232
228 class TestHG(_BaseTest):
233 class TestHG(TestController, _BaseTestCase, _BaseFixture):
229 REPO = HG_REPO
234 REPO = HG_REPO
230 NEW_REPO = NEW_HG_REPO
235 NEW_REPO = NEW_HG_REPO
231 REPO_TYPE = 'hg'
236 REPO_TYPE = 'hg'
@@ -13,7 +13,7 b' from kallithea.lib.vcs.utils.compat impo'
13 from kallithea.lib.vcs.nodes import FileNode
13 from kallithea.lib.vcs.nodes import FileNode
14
14
15
15
16 class BackendTestMixin(object):
16 class _BackendTestMixin(object):
17 """
17 """
18 This is a backend independent test case class which should be created
18 This is a backend independent test case class which should be created
19 with ``type`` method.
19 with ``type`` method.
@@ -103,7 +103,7 b' for alias in SCM_TESTS:'
103 'backend_alias': alias,
103 'backend_alias': alias,
104 }
104 }
105 cls_name = ''.join(('%s base backend test' % alias).title().split())
105 cls_name = ''.join(('%s base backend test' % alias).title().split())
106 bases = (BackendTestMixin, unittest.TestCase)
106 bases = (_BackendTestMixin, unittest.TestCase)
107 globals()[cls_name] = type(cls_name, bases, attrs)
107 globals()[cls_name] = type(cls_name, bases, attrs)
108
108
109
109
@@ -6,14 +6,14 b' import zipfile'
6 import datetime
6 import datetime
7 import tempfile
7 import tempfile
8 import StringIO
8 import StringIO
9 from kallithea.tests.vcs.base import BackendTestMixin
9 from kallithea.tests.vcs.base import _BackendTestMixin
10 from kallithea.tests.vcs.conf import SCM_TESTS
10 from kallithea.tests.vcs.conf import SCM_TESTS
11 from kallithea.lib.vcs.exceptions import VCSError
11 from kallithea.lib.vcs.exceptions import VCSError
12 from kallithea.lib.vcs.nodes import FileNode
12 from kallithea.lib.vcs.nodes import FileNode
13 from kallithea.lib.vcs.utils.compat import unittest
13 from kallithea.lib.vcs.utils.compat import unittest
14
14
15
15
16 class ArchivesTestCaseMixin(BackendTestMixin):
16 class ArchivesTestCaseMixin(_BackendTestMixin):
17
17
18 @classmethod
18 @classmethod
19 def _get_commits(cls):
19 def _get_commits(cls):
@@ -5,11 +5,11 b' from kallithea.lib import vcs'
5 from kallithea.lib.vcs.utils.compat import unittest
5 from kallithea.lib.vcs.utils.compat import unittest
6 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.nodes import FileNode
7
7
8 from kallithea.tests.vcs.base import BackendTestMixin
8 from kallithea.tests.vcs.base import _BackendTestMixin
9 from kallithea.tests.vcs.conf import SCM_TESTS
9 from kallithea.tests.vcs.conf import SCM_TESTS
10
10
11
11
12 class BranchesTestCaseMixin(BackendTestMixin):
12 class BranchesTestCaseMixin(_BackendTestMixin):
13
13
14 @classmethod
14 @classmethod
15 def _get_commits(cls):
15 def _get_commits(cls):
@@ -4,7 +4,7 b' from __future__ import with_statement'
4 import time
4 import time
5 import datetime
5 import datetime
6 from kallithea.lib import vcs
6 from kallithea.lib import vcs
7 from kallithea.tests.vcs.base import BackendTestMixin
7 from kallithea.tests.vcs.base import _BackendTestMixin
8 from kallithea.tests.vcs.conf import SCM_TESTS
8 from kallithea.tests.vcs.conf import SCM_TESTS
9
9
10 from kallithea.lib.vcs.backends.base import BaseChangeset
10 from kallithea.lib.vcs.backends.base import BaseChangeset
@@ -50,7 +50,7 b' class TestBaseChangeset(unittest.TestCas'
50 'removed': [],
50 'removed': [],
51 })
51 })
52
52
53 class ChangesetsWithCommitsTestCaseixin(BackendTestMixin):
53 class _ChangesetsWithCommitsTestCaseixin(_BackendTestMixin):
54 recreate_repo_per_test = True
54 recreate_repo_per_test = True
55
55
56 @classmethod
56 @classmethod
@@ -146,7 +146,7 b' class ChangesetsWithCommitsTestCaseixin('
146 self.assertEqual([sha], self.repo.get_changeset(test_rev).children)
146 self.assertEqual([sha], self.repo.get_changeset(test_rev).children)
147
147
148
148
149 class ChangesetsTestCaseMixin(BackendTestMixin):
149 class _ChangesetsTestCaseMixin(_BackendTestMixin):
150 recreate_repo_per_test = False
150 recreate_repo_per_test = False
151
151
152 @classmethod
152 @classmethod
@@ -301,7 +301,7 b' class ChangesetsTestCaseMixin(BackendTes'
301 list(self.repo.get_changesets(start=last-1, end=0))
301 list(self.repo.get_changesets(start=last-1, end=0))
302
302
303
303
304 class ChangesetsChangesTestCaseMixin(BackendTestMixin):
304 class _ChangesetsChangesTestCaseMixin(_BackendTestMixin):
305 recreate_repo_per_test = False
305 recreate_repo_per_test = False
306
306
307 @classmethod
307 @classmethod
@@ -373,17 +373,17 b' for alias in SCM_TESTS:'
373 }
373 }
374 # tests with additional commits
374 # tests with additional commits
375 cls_name = ''.join(('%s changesets with commits test' % alias).title().split())
375 cls_name = ''.join(('%s changesets with commits test' % alias).title().split())
376 bases = (ChangesetsWithCommitsTestCaseixin, unittest.TestCase)
376 bases = (_ChangesetsWithCommitsTestCaseixin, unittest.TestCase)
377 globals()[cls_name] = type(cls_name, bases, attrs)
377 globals()[cls_name] = type(cls_name, bases, attrs)
378
378
379 # tests without additional commits
379 # tests without additional commits
380 cls_name = ''.join(('%s changesets test' % alias).title().split())
380 cls_name = ''.join(('%s changesets test' % alias).title().split())
381 bases = (ChangesetsTestCaseMixin, unittest.TestCase)
381 bases = (_ChangesetsTestCaseMixin, unittest.TestCase)
382 globals()[cls_name] = type(cls_name, bases, attrs)
382 globals()[cls_name] = type(cls_name, bases, attrs)
383
383
384 # tests changes
384 # tests changes
385 cls_name = ''.join(('%s changesets changes test' % alias).title().split())
385 cls_name = ''.join(('%s changesets changes test' % alias).title().split())
386 bases = (ChangesetsChangesTestCaseMixin, unittest.TestCase)
386 bases = (_ChangesetsChangesTestCaseMixin, unittest.TestCase)
387 globals()[cls_name] = type(cls_name, bases, attrs)
387 globals()[cls_name] = type(cls_name, bases, attrs)
388
388
389
389
@@ -1,13 +1,13 b''
1 from __future__ import with_statement
1 from __future__ import with_statement
2
2
3 import datetime
3 import datetime
4 from kallithea.tests.vcs.base import BackendTestMixin
4 from kallithea.tests.vcs.base import _BackendTestMixin
5 from kallithea.tests.vcs.conf import SCM_TESTS
5 from kallithea.tests.vcs.conf import SCM_TESTS
6 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.nodes import FileNode
7 from kallithea.lib.vcs.utils.compat import unittest
7 from kallithea.lib.vcs.utils.compat import unittest
8
8
9
9
10 class GetitemTestCaseMixin(BackendTestMixin):
10 class GetitemTestCaseMixin(_BackendTestMixin):
11
11
12 @classmethod
12 @classmethod
13 def _get_commits(cls):
13 def _get_commits(cls):
@@ -1,13 +1,13 b''
1 from __future__ import with_statement
1 from __future__ import with_statement
2
2
3 import datetime
3 import datetime
4 from kallithea.tests.vcs.base import BackendTestMixin
4 from kallithea.tests.vcs.base import _BackendTestMixin
5 from kallithea.tests.vcs.conf import SCM_TESTS
5 from kallithea.tests.vcs.conf import SCM_TESTS
6 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.nodes import FileNode
7 from kallithea.lib.vcs.utils.compat import unittest
7 from kallithea.lib.vcs.utils.compat import unittest
8
8
9
9
10 class GetsliceTestCaseMixin(BackendTestMixin):
10 class GetsliceTestCaseMixin(_BackendTestMixin):
11
11
12 @classmethod
12 @classmethod
13 def _get_commits(cls):
13 def _get_commits(cls):
@@ -8,7 +8,7 b' from kallithea.lib.vcs.backends.git impo'
8 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
8 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
9 from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
9 from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
10 from kallithea.lib.vcs.utils.compat import unittest
10 from kallithea.lib.vcs.utils.compat import unittest
11 from kallithea.tests.vcs.base import BackendTestMixin
11 from kallithea.tests.vcs.base import _BackendTestMixin
12 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, get_new_dir
12 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, get_new_dir
13
13
14
14
@@ -620,7 +620,7 b' class GitSpecificTest(unittest.TestCase)'
620 changeset.added
620 changeset.added
621
621
622
622
623 class GitSpecificWithRepoTest(BackendTestMixin, unittest.TestCase):
623 class GitSpecificWithRepoTest(_BackendTestMixin, unittest.TestCase):
624 backend_alias = 'git'
624 backend_alias = 'git'
625
625
626 @classmethod
626 @classmethod
@@ -688,7 +688,7 b' class GitSpecificWithRepoTest(BackendTes'
688 % (3, self.repo._get_revision(0), self.repo._get_revision(1)))
688 % (3, self.repo._get_revision(0), self.repo._get_revision(1)))
689
689
690
690
691 class GitRegressionTest(BackendTestMixin, unittest.TestCase):
691 class GitRegressionTest(_BackendTestMixin, unittest.TestCase):
692 backend_alias = 'git'
692 backend_alias = 'git'
693
693
694 @classmethod
694 @classmethod
@@ -1,6 +1,6 b''
1 from __future__ import with_statement
1 from __future__ import with_statement
2 import datetime
2 import datetime
3 from kallithea.tests.vcs.base import BackendTestMixin
3 from kallithea.tests.vcs.base import _BackendTestMixin
4 from kallithea.tests.vcs.conf import SCM_TESTS
4 from kallithea.tests.vcs.conf import SCM_TESTS
5 from kallithea.tests.vcs.conf import TEST_USER_CONFIG_FILE
5 from kallithea.tests.vcs.conf import TEST_USER_CONFIG_FILE
6 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.nodes import FileNode
@@ -8,7 +8,7 b' from kallithea.lib.vcs.utils.compat impo'
8 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
8 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
9
9
10
10
11 class RepositoryBaseTest(BackendTestMixin):
11 class RepositoryBaseTest(_BackendTestMixin):
12 recreate_repo_per_test = False
12 recreate_repo_per_test = False
13
13
14 @classmethod
14 @classmethod
@@ -46,7 +46,7 b' class RepositoryBaseTest(BackendTestMixi'
46 self.assertTrue(self.repo != dummy())
46 self.assertTrue(self.repo != dummy())
47
47
48
48
49 class RepositoryGetDiffTest(BackendTestMixin):
49 class RepositoryGetDiffTest(_BackendTestMixin):
50
50
51 @classmethod
51 @classmethod
52 def _get_commits(cls):
52 def _get_commits(cls):
@@ -1,13 +1,13 b''
1 from __future__ import with_statement
1 from __future__ import with_statement
2
2
3 from kallithea.tests.vcs.base import BackendTestMixin
3 from kallithea.tests.vcs.base import _BackendTestMixin
4 from kallithea.tests.vcs.conf import SCM_TESTS
4 from kallithea.tests.vcs.conf import SCM_TESTS
5 from kallithea.lib.vcs.exceptions import TagAlreadyExistError
5 from kallithea.lib.vcs.exceptions import TagAlreadyExistError
6 from kallithea.lib.vcs.exceptions import TagDoesNotExistError
6 from kallithea.lib.vcs.exceptions import TagDoesNotExistError
7 from kallithea.lib.vcs.utils.compat import unittest
7 from kallithea.lib.vcs.utils.compat import unittest
8
8
9
9
10 class TagsTestCaseMixin(BackendTestMixin):
10 class TagsTestCaseMixin(_BackendTestMixin):
11
11
12 def test_new_tag(self):
12 def test_new_tag(self):
13 tip = self.repo.get_changeset()
13 tip = self.repo.get_changeset()
@@ -3,11 +3,11 b' from __future__ import with_statement'
3 import datetime
3 import datetime
4 from kallithea.lib.vcs.nodes import FileNode
4 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.utils.compat import unittest
5 from kallithea.lib.vcs.utils.compat import unittest
6 from kallithea.tests.vcs.base import BackendTestMixin
6 from kallithea.tests.vcs.base import _BackendTestMixin
7 from kallithea.tests.vcs.conf import SCM_TESTS
7 from kallithea.tests.vcs.conf import SCM_TESTS
8
8
9
9
10 class WorkdirTestCaseMixin(BackendTestMixin):
10 class WorkdirTestCaseMixin(_BackendTestMixin):
11
11
12 @classmethod
12 @classmethod
13 def _get_commits(cls):
13 def _get_commits(cls):
General Comments 0
You need to be logged in to leave comments. Login now