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