##// END OF EJS Templates
tests: cleanup imports
Branko Majic -
r7045:5c9eb37b default
parent child Browse files
Show More
@@ -6,28 +6,20 b' run for each engine listed at ``conf.SCM'
6 ``vcs.backends.BACKENDS``.
6 ``vcs.backends.BACKENDS``.
7
7
8 For each SCM we run tests for, we need some repository. We would use
8 For each SCM we run tests for, we need some repository. We would use
9 repositories location from system environment variables or test suite defaults
9 repositories location provided in test suite defaults - see ``conf``
10 - see ``conf`` module for more detail. We simply try to check if repository at
10 module for more detail. We simply try to check if repository at
11 certain location exists, if not we would try to fetch them. At ``test_vcs`` or
11 certain location exists, if not we would try to fetch them. At
12 ``test_common`` we run unit tests common for each repository type and for
12 ``test_vcs`` or ``test_common`` we run unit tests common for each
13 example specific mercurial tests are located at ``test_hg`` module.
13 repository type and for example specific mercurial tests are located
14
14 at ``test_hg`` module.
15 Oh, and tests are run with ``unittest.collector`` wrapped by ``collector``
16 function at ``tests/__init__.py``.
17
18 .. _vcs: http://bitbucket.org/marcinkuzminski/vcs
19 .. _unittest: http://pypi.python.org/pypi/unittest
20
21 """
15 """
22
16
23 import os
17 import os
24 import shutil
18 import shutil
25
19
26 from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO
20 from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO, TESTS_TMP_PATH
27 from kallithea.tests.vcs.utils import SCMFetcher
21 from kallithea.tests.vcs.utils import SCMFetcher
28
22
29 from kallithea.tests.base import *
30
31
23
32 # Base directory for the VCS tests.
24 # Base directory for the VCS tests.
33 VCS_TEST_MODULE_BASE_DIR = os.path.abspath(os.path.dirname(__file__))
25 VCS_TEST_MODULE_BASE_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -6,12 +6,13 b' import os'
6 import time
6 import time
7 import shutil
7 import shutil
8 import datetime
8 import datetime
9 from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir
10
9
11 from kallithea.lib import vcs
10 from kallithea.lib import vcs
12 from kallithea.lib.vcs.utils.compat import unittest
11 from kallithea.lib.vcs.utils.compat import unittest
13 from kallithea.lib.vcs.nodes import FileNode
12 from kallithea.lib.vcs.nodes import FileNode
14
13
14 from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir
15
15
16
16 class _BackendTestMixin(object):
17 class _BackendTestMixin(object):
17 """
18 """
@@ -10,11 +10,14 b' import uuid'
10 from kallithea.tests.base import (
10 from kallithea.tests.base import (
11 TESTS_TMP_PATH, SCM_TESTS,
11 TESTS_TMP_PATH, SCM_TESTS,
12 TEST_HG_REPO, HG_REMOTE_REPO,
12 TEST_HG_REPO, HG_REMOTE_REPO,
13 TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL,
13 TEST_GIT_REPO, GIT_REMOTE_REPO,
14 TEST_GIT_REPO, GIT_REMOTE_REPO,
15 TEST_GIT_REPO_CLONE,
14 )
16 )
15
17
16 __all__ = (
18 __all__ = (
17 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
19 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
20 'TEST_HG_REPO_CLONE', 'TEST_GIT_REPO_CLONE', 'TEST_HG_REPO_PULL',
18 'SCM_TESTS',
21 'SCM_TESTS',
19 )
22 )
20
23
@@ -54,7 +57,3 b' def get_new_dir(title=None):'
54 hex_uuid = uuid.uuid4().hex
57 hex_uuid = uuid.uuid4().hex
55
58
56 return "%s-%s" % (path, hex_uuid)
59 return "%s-%s" % (path, hex_uuid)
57
58
59 # overide default configurations with kallithea ones
60 from kallithea.tests.base import *
@@ -5,11 +5,13 b' import datetime'
5 import tempfile
5 import tempfile
6 import StringIO
6 import StringIO
7
7
8 from kallithea.lib.vcs.utils.compat import unittest
9
10 from kallithea.lib.vcs.exceptions import VCSError
11 from kallithea.lib.vcs.nodes import FileNode
12
8 from kallithea.tests.vcs.base import _BackendTestMixin
13 from kallithea.tests.vcs.base import _BackendTestMixin
9 from kallithea.tests.vcs.conf import SCM_TESTS, TESTS_TMP_PATH
14 from kallithea.tests.vcs.conf import SCM_TESTS, TESTS_TMP_PATH
10 from kallithea.lib.vcs.exceptions import VCSError
11 from kallithea.lib.vcs.nodes import FileNode
12 from kallithea.lib.vcs.utils.compat import unittest
13
15
14
16
15 class ArchivesTestCaseMixin(_BackendTestMixin):
17 class ArchivesTestCaseMixin(_BackendTestMixin):
@@ -2,9 +2,10 b''
2
2
3 import time
3 import time
4 import datetime
4 import datetime
5
6 from kallithea.lib.vcs.utils.compat import unittest
7
5 from kallithea.lib import vcs
8 from kallithea.lib import vcs
6 from kallithea.tests.vcs.base import _BackendTestMixin
7 from kallithea.tests.vcs.conf import SCM_TESTS
8
9
9 from kallithea.lib.vcs.backends.base import BaseChangeset
10 from kallithea.lib.vcs.backends.base import BaseChangeset
10 from kallithea.lib.vcs.nodes import (
11 from kallithea.lib.vcs.nodes import (
@@ -15,8 +16,9 b' from kallithea.lib.vcs.exceptions import'
15 BranchDoesNotExistError, ChangesetDoesNotExistError,
16 BranchDoesNotExistError, ChangesetDoesNotExistError,
16 RepositoryError, EmptyRepositoryError
17 RepositoryError, EmptyRepositoryError
17 )
18 )
18 from kallithea.lib.vcs.utils.compat import unittest
19
19 from kallithea.tests.vcs.conf import get_new_dir
20 from kallithea.tests.vcs.base import _BackendTestMixin
21 from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir
20
22
21
23
22 class TestBaseChangeset(unittest.TestCase):
24 class TestBaseChangeset(unittest.TestCase):
@@ -1,7 +1,7 b''
1 # encoding: utf8
1 # encoding: utf8
2
2
3 import datetime
3
4
4 import datetime
5 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.tests.vcs.test_inmemchangesets import BackendBaseTestCase
6 from kallithea.tests.vcs.test_inmemchangesets import BackendBaseTestCase
7 from kallithea.tests.vcs.conf import SCM_TESTS
7 from kallithea.tests.vcs.conf import SCM_TESTS
@@ -1,4 +1,5 b''
1 import datetime
1 import datetime
2
2 from kallithea.tests.vcs.base import _BackendTestMixin
3 from kallithea.tests.vcs.base import _BackendTestMixin
3 from kallithea.tests.vcs.conf import SCM_TESTS
4 from kallithea.tests.vcs.conf import SCM_TESTS
4 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.nodes import FileNode
@@ -1,8 +1,11 b''
1 import datetime
1 import datetime
2
3 from kallithea.lib.vcs.nodes import FileNode
4
5 from kallithea.lib.vcs.utils.compat import unittest
6
2 from kallithea.tests.vcs.base import _BackendTestMixin
7 from kallithea.tests.vcs.base import _BackendTestMixin
3 from kallithea.tests.vcs.conf import SCM_TESTS
8 from kallithea.tests.vcs.conf import SCM_TESTS
4 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.utils.compat import unittest
6
9
7
10
8 class GetsliceTestCaseMixin(_BackendTestMixin):
11 class GetsliceTestCaseMixin(_BackendTestMixin):
@@ -11,6 +11,7 b' from kallithea.lib.vcs.exceptions import'
11 from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
11 from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
12 from kallithea.lib.vcs.utils.compat import unittest
12 from kallithea.lib.vcs.utils.compat import unittest
13 from kallithea.model.scm import ScmModel
13 from kallithea.model.scm import ScmModel
14
14 from kallithea.tests.vcs.base import _BackendTestMixin
15 from kallithea.tests.vcs.base import _BackendTestMixin
15 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir
16 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir
16
17
@@ -6,6 +6,7 b' from kallithea.lib.utils2 import safe_st'
6 from kallithea.lib.vcs.backends.hg import MercurialRepository, MercurialChangeset
6 from kallithea.lib.vcs.backends.hg import MercurialRepository, MercurialChangeset
7 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
7 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
8 from kallithea.lib.vcs.nodes import NodeKind, NodeState
8 from kallithea.lib.vcs.nodes import NodeKind, NodeState
9
9 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \
10 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \
10 TEST_HG_REPO_PULL, TESTS_TMP_PATH
11 TEST_HG_REPO_PULL, TESTS_TMP_PATH
11 from kallithea.lib.vcs.utils.compat import unittest
12 from kallithea.lib.vcs.utils.compat import unittest
@@ -6,8 +6,9 b' Tests so called "in memory changesets" c'
6 import time
6 import time
7 import datetime
7 import datetime
8
8
9 from kallithea.lib.vcs.utils.compat import unittest
10
9 from kallithea.lib import vcs
11 from kallithea.lib import vcs
10 from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir
11 from kallithea.lib.vcs.exceptions import EmptyRepositoryError
12 from kallithea.lib.vcs.exceptions import EmptyRepositoryError
12 from kallithea.lib.vcs.exceptions import NodeAlreadyAddedError
13 from kallithea.lib.vcs.exceptions import NodeAlreadyAddedError
13 from kallithea.lib.vcs.exceptions import NodeAlreadyExistsError
14 from kallithea.lib.vcs.exceptions import NodeAlreadyExistsError
@@ -17,9 +18,10 b' from kallithea.lib.vcs.exceptions import'
17 from kallithea.lib.vcs.exceptions import NodeNotChangedError
18 from kallithea.lib.vcs.exceptions import NodeNotChangedError
18 from kallithea.lib.vcs.nodes import DirNode
19 from kallithea.lib.vcs.nodes import DirNode
19 from kallithea.lib.vcs.nodes import FileNode
20 from kallithea.lib.vcs.nodes import FileNode
20 from kallithea.lib.vcs.utils.compat import unittest
21 from kallithea.lib.vcs.utils import safe_unicode
21 from kallithea.lib.vcs.utils import safe_unicode
22
22
23 from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir
24
23
25
24 class InMemoryChangesetTestMixin(object):
26 class InMemoryChangesetTestMixin(object):
25 """
27 """
@@ -1,11 +1,13 b''
1 import stat
1 import stat
2 import mimetypes
2 import mimetypes
3
4 from kallithea.lib.vcs.utils.compat import unittest
5
3 from kallithea.lib.vcs.nodes import DirNode
6 from kallithea.lib.vcs.nodes import DirNode
4 from kallithea.lib.vcs.nodes import FileNode
7 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.nodes import Node
8 from kallithea.lib.vcs.nodes import Node
6 from kallithea.lib.vcs.nodes import NodeError
9 from kallithea.lib.vcs.nodes import NodeError
7 from kallithea.lib.vcs.nodes import NodeKind
10 from kallithea.lib.vcs.nodes import NodeKind
8 from kallithea.lib.vcs.utils.compat import unittest
9
11
10
12
11 class NodeBasicTest(unittest.TestCase):
13 class NodeBasicTest(unittest.TestCase):
@@ -1,10 +1,13 b''
1 import datetime
1 import datetime
2
3 from kallithea.lib.vcs.utils.compat import unittest
4
5 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
7
2 from kallithea.tests.vcs.base import _BackendTestMixin
8 from kallithea.tests.vcs.base import _BackendTestMixin
3 from kallithea.tests.vcs.conf import SCM_TESTS
9 from kallithea.tests.vcs.conf import SCM_TESTS
4 from kallithea.tests.vcs import TEST_USER_CONFIG_FILE
10 from kallithea.tests.vcs import TEST_USER_CONFIG_FILE
5 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.utils.compat import unittest
7 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
8
11
9
12
10 class RepositoryBaseTest(_BackendTestMixin):
13 class RepositoryBaseTest(_BackendTestMixin):
@@ -1,8 +1,10 b''
1 from kallithea.lib.vcs.utils.compat import unittest
2
3 from kallithea.lib.vcs.exceptions import TagAlreadyExistError
4 from kallithea.lib.vcs.exceptions import TagDoesNotExistError
5
1 from kallithea.tests.vcs.base import _BackendTestMixin
6 from kallithea.tests.vcs.base import _BackendTestMixin
2 from kallithea.tests.vcs.conf import SCM_TESTS
7 from kallithea.tests.vcs.conf import SCM_TESTS
3 from kallithea.lib.vcs.exceptions import TagAlreadyExistError
4 from kallithea.lib.vcs.exceptions import TagDoesNotExistError
5 from kallithea.lib.vcs.utils.compat import unittest
6
8
7
9
8 class TagsTestCaseMixin(_BackendTestMixin):
10 class TagsTestCaseMixin(_BackendTestMixin):
@@ -7,6 +7,7 b' import shutil'
7 import datetime
7 import datetime
8
8
9 from kallithea.lib.vcs.utils.compat import unittest
9 from kallithea.lib.vcs.utils.compat import unittest
10
10 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
11 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
11 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
12 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
12 from kallithea.lib.vcs.utils.helpers import get_scm
13 from kallithea.lib.vcs.utils.helpers import get_scm
@@ -1,10 +1,12 b''
1 import os
1 import os
2 import shutil
2 import shutil
3
3
4 from kallithea.lib.vcs.utils.compat import unittest
5
4 from kallithea.lib.utils2 import safe_str
6 from kallithea.lib.utils2 import safe_str
5 from kallithea.lib.vcs import VCSError, get_repo, get_backend
7 from kallithea.lib.vcs import VCSError, get_repo, get_backend
6 from kallithea.lib.vcs.backends.hg import MercurialRepository
8 from kallithea.lib.vcs.backends.hg import MercurialRepository
7 from kallithea.lib.vcs.utils.compat import unittest
9
8 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
10 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
9
11
10
12
@@ -1,6 +1,9 b''
1 import datetime
1 import datetime
2
3 from kallithea.lib.vcs.utils.compat import unittest
4
2 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.nodes import FileNode
3 from kallithea.lib.vcs.utils.compat import unittest
6
4 from kallithea.tests.vcs.base import _BackendTestMixin
7 from kallithea.tests.vcs.base import _BackendTestMixin
5 from kallithea.tests.vcs.conf import SCM_TESTS
8 from kallithea.tests.vcs.conf import SCM_TESTS
6
9
General Comments 0
You need to be logged in to leave comments. Login now