# HG changeset patch # User Branko Majic # Date 2018-02-10 17:50:02 # Node ID 5c9eb37bdec48952c3a36e920ba3250976d19ee6 # Parent 191d377abad03d8c5c65918af38094629cdc1df9 tests: cleanup imports diff --git a/kallithea/tests/vcs/__init__.py b/kallithea/tests/vcs/__init__.py --- a/kallithea/tests/vcs/__init__.py +++ b/kallithea/tests/vcs/__init__.py @@ -6,28 +6,20 @@ run for each engine listed at ``conf.SCM ``vcs.backends.BACKENDS``. For each SCM we run tests for, we need some repository. We would use -repositories location from system environment variables or test suite defaults -- see ``conf`` module for more detail. We simply try to check if repository at -certain location exists, if not we would try to fetch them. At ``test_vcs`` or -``test_common`` we run unit tests common for each repository type and for -example specific mercurial tests are located at ``test_hg`` module. - -Oh, and tests are run with ``unittest.collector`` wrapped by ``collector`` -function at ``tests/__init__.py``. - -.. _vcs: http://bitbucket.org/marcinkuzminski/vcs -.. _unittest: http://pypi.python.org/pypi/unittest - +repositories location provided in test suite defaults - see ``conf`` +module for more detail. We simply try to check if repository at +certain location exists, if not we would try to fetch them. At +``test_vcs`` or ``test_common`` we run unit tests common for each +repository type and for example specific mercurial tests are located +at ``test_hg`` module. """ import os import shutil -from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO +from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO, TESTS_TMP_PATH from kallithea.tests.vcs.utils import SCMFetcher -from kallithea.tests.base import * - # Base directory for the VCS tests. VCS_TEST_MODULE_BASE_DIR = os.path.abspath(os.path.dirname(__file__)) diff --git a/kallithea/tests/vcs/base.py b/kallithea/tests/vcs/base.py --- a/kallithea/tests/vcs/base.py +++ b/kallithea/tests/vcs/base.py @@ -6,12 +6,13 @@ import os import time import shutil import datetime -from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir from kallithea.lib import vcs from kallithea.lib.vcs.utils.compat import unittest from kallithea.lib.vcs.nodes import FileNode +from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir + class _BackendTestMixin(object): """ diff --git a/kallithea/tests/vcs/conf.py b/kallithea/tests/vcs/conf.py --- a/kallithea/tests/vcs/conf.py +++ b/kallithea/tests/vcs/conf.py @@ -10,11 +10,14 @@ import uuid from kallithea.tests.base import ( TESTS_TMP_PATH, SCM_TESTS, TEST_HG_REPO, HG_REMOTE_REPO, + TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL, TEST_GIT_REPO, GIT_REMOTE_REPO, + TEST_GIT_REPO_CLONE, ) __all__ = ( 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO', + 'TEST_HG_REPO_CLONE', 'TEST_GIT_REPO_CLONE', 'TEST_HG_REPO_PULL', 'SCM_TESTS', ) @@ -54,7 +57,3 @@ def get_new_dir(title=None): hex_uuid = uuid.uuid4().hex return "%s-%s" % (path, hex_uuid) - - -# overide default configurations with kallithea ones -from kallithea.tests.base import * diff --git a/kallithea/tests/vcs/test_archives.py b/kallithea/tests/vcs/test_archives.py --- a/kallithea/tests/vcs/test_archives.py +++ b/kallithea/tests/vcs/test_archives.py @@ -5,11 +5,13 @@ import datetime import tempfile import StringIO +from kallithea.lib.vcs.utils.compat import unittest + +from kallithea.lib.vcs.exceptions import VCSError +from kallithea.lib.vcs.nodes import FileNode + from kallithea.tests.vcs.base import _BackendTestMixin from kallithea.tests.vcs.conf import SCM_TESTS, TESTS_TMP_PATH -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): diff --git a/kallithea/tests/vcs/test_changesets.py b/kallithea/tests/vcs/test_changesets.py --- a/kallithea/tests/vcs/test_changesets.py +++ b/kallithea/tests/vcs/test_changesets.py @@ -2,9 +2,10 @@ import time import datetime + +from kallithea.lib.vcs.utils.compat import unittest + from kallithea.lib import vcs -from kallithea.tests.vcs.base import _BackendTestMixin -from kallithea.tests.vcs.conf import SCM_TESTS from kallithea.lib.vcs.backends.base import BaseChangeset from kallithea.lib.vcs.nodes import ( @@ -15,8 +16,9 @@ from kallithea.lib.vcs.exceptions import BranchDoesNotExistError, ChangesetDoesNotExistError, RepositoryError, EmptyRepositoryError ) -from kallithea.lib.vcs.utils.compat import unittest -from kallithea.tests.vcs.conf import get_new_dir + +from kallithea.tests.vcs.base import _BackendTestMixin +from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir class TestBaseChangeset(unittest.TestCase): diff --git a/kallithea/tests/vcs/test_filenodes_unicode_path.py b/kallithea/tests/vcs/test_filenodes_unicode_path.py --- a/kallithea/tests/vcs/test_filenodes_unicode_path.py +++ b/kallithea/tests/vcs/test_filenodes_unicode_path.py @@ -1,7 +1,7 @@ # encoding: utf8 +import datetime -import datetime from kallithea.lib.vcs.nodes import FileNode from kallithea.tests.vcs.test_inmemchangesets import BackendBaseTestCase from kallithea.tests.vcs.conf import SCM_TESTS diff --git a/kallithea/tests/vcs/test_getitem.py b/kallithea/tests/vcs/test_getitem.py --- a/kallithea/tests/vcs/test_getitem.py +++ b/kallithea/tests/vcs/test_getitem.py @@ -1,4 +1,5 @@ import datetime + from kallithea.tests.vcs.base import _BackendTestMixin from kallithea.tests.vcs.conf import SCM_TESTS from kallithea.lib.vcs.nodes import FileNode diff --git a/kallithea/tests/vcs/test_getslice.py b/kallithea/tests/vcs/test_getslice.py --- a/kallithea/tests/vcs/test_getslice.py +++ b/kallithea/tests/vcs/test_getslice.py @@ -1,8 +1,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.conf import SCM_TESTS -from kallithea.lib.vcs.nodes import FileNode -from kallithea.lib.vcs.utils.compat import unittest class GetsliceTestCaseMixin(_BackendTestMixin): diff --git a/kallithea/tests/vcs/test_git.py b/kallithea/tests/vcs/test_git.py --- a/kallithea/tests/vcs/test_git.py +++ b/kallithea/tests/vcs/test_git.py @@ -11,6 +11,7 @@ from kallithea.lib.vcs.exceptions import from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState from kallithea.lib.vcs.utils.compat import unittest from kallithea.model.scm import ScmModel + from kallithea.tests.vcs.base import _BackendTestMixin from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir diff --git a/kallithea/tests/vcs/test_hg.py b/kallithea/tests/vcs/test_hg.py --- a/kallithea/tests/vcs/test_hg.py +++ b/kallithea/tests/vcs/test_hg.py @@ -6,6 +6,7 @@ from kallithea.lib.utils2 import safe_st from kallithea.lib.vcs.backends.hg import MercurialRepository, MercurialChangeset from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError from kallithea.lib.vcs.nodes import NodeKind, NodeState + from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \ TEST_HG_REPO_PULL, TESTS_TMP_PATH from kallithea.lib.vcs.utils.compat import unittest diff --git a/kallithea/tests/vcs/test_inmemchangesets.py b/kallithea/tests/vcs/test_inmemchangesets.py --- a/kallithea/tests/vcs/test_inmemchangesets.py +++ b/kallithea/tests/vcs/test_inmemchangesets.py @@ -6,8 +6,9 @@ Tests so called "in memory changesets" c import time import datetime +from kallithea.lib.vcs.utils.compat import unittest + from kallithea.lib import vcs -from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir from kallithea.lib.vcs.exceptions import EmptyRepositoryError from kallithea.lib.vcs.exceptions import NodeAlreadyAddedError from kallithea.lib.vcs.exceptions import NodeAlreadyExistsError @@ -17,9 +18,10 @@ from kallithea.lib.vcs.exceptions import from kallithea.lib.vcs.exceptions import NodeNotChangedError from kallithea.lib.vcs.nodes import DirNode from kallithea.lib.vcs.nodes import FileNode -from kallithea.lib.vcs.utils.compat import unittest from kallithea.lib.vcs.utils import safe_unicode +from kallithea.tests.vcs.conf import SCM_TESTS, get_new_dir + class InMemoryChangesetTestMixin(object): """ diff --git a/kallithea/tests/vcs/test_nodes.py b/kallithea/tests/vcs/test_nodes.py --- a/kallithea/tests/vcs/test_nodes.py +++ b/kallithea/tests/vcs/test_nodes.py @@ -1,11 +1,13 @@ import stat import mimetypes + +from kallithea.lib.vcs.utils.compat import unittest + from kallithea.lib.vcs.nodes import DirNode from kallithea.lib.vcs.nodes import FileNode from kallithea.lib.vcs.nodes import Node from kallithea.lib.vcs.nodes import NodeError from kallithea.lib.vcs.nodes import NodeKind -from kallithea.lib.vcs.utils.compat import unittest class NodeBasicTest(unittest.TestCase): diff --git a/kallithea/tests/vcs/test_repository.py b/kallithea/tests/vcs/test_repository.py --- a/kallithea/tests/vcs/test_repository.py +++ b/kallithea/tests/vcs/test_repository.py @@ -1,10 +1,13 @@ import datetime + +from kallithea.lib.vcs.utils.compat import unittest + +from kallithea.lib.vcs.nodes import FileNode +from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError + from kallithea.tests.vcs.base import _BackendTestMixin from kallithea.tests.vcs.conf import SCM_TESTS from kallithea.tests.vcs import TEST_USER_CONFIG_FILE -from kallithea.lib.vcs.nodes import FileNode -from kallithea.lib.vcs.utils.compat import unittest -from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError class RepositoryBaseTest(_BackendTestMixin): diff --git a/kallithea/tests/vcs/test_tags.py b/kallithea/tests/vcs/test_tags.py --- a/kallithea/tests/vcs/test_tags.py +++ b/kallithea/tests/vcs/test_tags.py @@ -1,8 +1,10 @@ +from kallithea.lib.vcs.utils.compat import unittest + +from kallithea.lib.vcs.exceptions import TagAlreadyExistError +from kallithea.lib.vcs.exceptions import TagDoesNotExistError + 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): diff --git a/kallithea/tests/vcs/test_utils.py b/kallithea/tests/vcs/test_utils.py --- a/kallithea/tests/vcs/test_utils.py +++ b/kallithea/tests/vcs/test_utils.py @@ -7,6 +7,7 @@ import shutil import datetime from kallithea.lib.vcs.utils.compat import unittest + from kallithea.lib.vcs.utils.paths import get_dirs_for_path from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs from kallithea.lib.vcs.utils.helpers import get_scm diff --git a/kallithea/tests/vcs/test_vcs.py b/kallithea/tests/vcs/test_vcs.py --- a/kallithea/tests/vcs/test_vcs.py +++ b/kallithea/tests/vcs/test_vcs.py @@ -1,10 +1,12 @@ import os import shutil +from kallithea.lib.vcs.utils.compat import unittest + from kallithea.lib.utils2 import safe_str from kallithea.lib.vcs import VCSError, get_repo, get_backend from kallithea.lib.vcs.backends.hg import MercurialRepository -from kallithea.lib.vcs.utils.compat import unittest + from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH diff --git a/kallithea/tests/vcs/test_workdirs.py b/kallithea/tests/vcs/test_workdirs.py --- a/kallithea/tests/vcs/test_workdirs.py +++ b/kallithea/tests/vcs/test_workdirs.py @@ -1,6 +1,9 @@ import datetime + +from kallithea.lib.vcs.utils.compat import unittest + 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.conf import SCM_TESTS