From 245331a60d743b7b73ba3a8b15e6f4648273369f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sat, 13 Apr 2024 23:52:16 +0100 Subject: [PATCH] Move tests to root. Fixes #1024 --- .github/workflows/python-distributions.yml | 2 +- .github/workflows/pythontest.yml | 2 +- .stestr.conf | 2 +- .testr.conf | 2 +- Makefile | 12 +++---- NEWS | 2 ++ dulwich/contrib/README.swift.rst | 4 +-- dulwich/contrib/__init__.py | 12 ------- pyproject.toml | 2 -- {dulwich/tests => tests}/__init__.py | 12 +++---- {dulwich/tests => tests}/compat/__init__.py | 2 +- .../tests => tests}/compat/server_utils.py | 9 +++--- .../tests => tests}/compat/test_client.py | 2 +- {dulwich/tests => tests}/compat/test_pack.py | 6 ++-- {dulwich/tests => tests}/compat/test_patch.py | 2 +- .../tests => tests}/compat/test_porcelain.py | 0 .../tests => tests}/compat/test_repository.py | 5 +-- .../tests => tests}/compat/test_server.py | 4 +-- {dulwich/tests => tests}/compat/test_utils.py | 4 +-- {dulwich/tests => tests}/compat/test_web.py | 8 ++--- {dulwich/tests => tests}/compat/utils.py | 8 ++--- tests/contrib/__init__.py | 31 +++++++++++++++++++ .../contrib/test_paramiko_vendor.py | 4 +-- .../contrib/test_release_robot.py | 4 +-- {dulwich => tests}/contrib/test_swift.py | 6 ++-- .../contrib/test_swift_smoke.py | 0 {dulwich/tests => tests}/test_archive.py | 8 ++--- {dulwich/tests => tests}/test_blackbox.py | 4 +-- {dulwich/tests => tests}/test_bundle.py | 6 ++-- {dulwich/tests => tests}/test_client.py | 16 +++++----- {dulwich/tests => tests}/test_config.py | 6 ++-- {dulwich/tests => tests}/test_credentials.py | 10 ++++-- {dulwich/tests => tests}/test_diff_tree.py | 12 +++---- {dulwich/tests => tests}/test_fastexport.py | 12 +++---- {dulwich/tests => tests}/test_file.py | 4 +-- {dulwich/tests => tests}/test_grafts.py | 8 ++--- {dulwich/tests => tests}/test_graph.py | 6 ++-- {dulwich/tests => tests}/test_greenthreads.py | 6 ++-- {dulwich/tests => tests}/test_hooks.py | 4 +-- {dulwich/tests => tests}/test_ignore.py | 8 ++--- {dulwich/tests => tests}/test_index.py | 14 ++++----- {dulwich/tests => tests}/test_lfs.py | 3 +- {dulwich/tests => tests}/test_line_ending.py | 8 ++--- {dulwich/tests => tests}/test_lru_cache.py | 3 +- {dulwich/tests => tests}/test_mailmap.py | 2 +- .../test_missing_obj_finder.py | 6 ++-- {dulwich/tests => tests}/test_object_store.py | 16 +++++----- {dulwich/tests => tests}/test_objects.py | 12 +++---- {dulwich/tests => tests}/test_objectspec.py | 10 +++--- {dulwich/tests => tests}/test_pack.py | 16 +++++----- {dulwich/tests => tests}/test_patch.py | 10 +++--- {dulwich/tests => tests}/test_porcelain.py | 18 +++++------ {dulwich/tests => tests}/test_protocol.py | 8 ++--- {dulwich/tests => tests}/test_reflog.py | 8 ++--- {dulwich/tests => tests}/test_refs.py | 12 +++---- {dulwich/tests => tests}/test_repository.py | 14 ++++----- {dulwich/tests => tests}/test_server.py | 16 +++++----- {dulwich/tests => tests}/test_stash.py | 5 +-- {dulwich/tests => tests}/test_utils.py | 6 ++-- {dulwich/tests => tests}/test_walk.py | 12 +++---- {dulwich/tests => tests}/test_web.py | 14 ++++----- {dulwich/tests => tests}/utils.py | 14 ++++----- 62 files changed, 256 insertions(+), 228 deletions(-) rename {dulwich/tests => tests}/__init__.py (94%) rename {dulwich/tests => tests}/compat/__init__.py (94%) rename {dulwich/tests => tests}/compat/server_utils.py (98%) rename {dulwich/tests => tests}/compat/test_client.py (99%) rename {dulwich/tests => tests}/compat/test_pack.py (98%) rename {dulwich/tests => tests}/compat/test_patch.py (99%) rename {dulwich/tests => tests}/compat/test_porcelain.py (100%) rename {dulwich/tests => tests}/compat/test_repository.py (99%) rename {dulwich/tests => tests}/compat/test_server.py (97%) rename {dulwich/tests => tests}/compat/test_utils.py (97%) rename {dulwich/tests => tests}/compat/test_web.py (98%) rename {dulwich/tests => tests}/compat/utils.py (97%) create mode 100644 tests/contrib/__init__.py rename {dulwich => tests}/contrib/test_paramiko_vendor.py (98%) rename {dulwich => tests}/contrib/test_release_robot.py (98%) rename {dulwich => tests}/contrib/test_swift.py (99%) rename {dulwich => tests}/contrib/test_swift_smoke.py (100%) rename {dulwich/tests => tests}/test_archive.py (95%) rename {dulwich/tests => tests}/test_blackbox.py (97%) rename {dulwich/tests => tests}/test_bundle.py (92%) rename {dulwich/tests => tests}/test_client.py (99%) rename {dulwich/tests => tests}/test_config.py (99%) rename {dulwich/tests => tests}/test_credentials.py (94%) rename {dulwich/tests => tests}/test_diff_tree.py (99%) rename {dulwich/tests => tests}/test_fastexport.py (97%) rename {dulwich/tests => tests}/test_file.py (98%) rename {dulwich/tests => tests}/test_grafts.py (97%) rename {dulwich/tests => tests}/test_graph.py (98%) rename {dulwich/tests => tests}/test_greenthreads.py (95%) rename {dulwich/tests => tests}/test_hooks.py (97%) rename {dulwich/tests => tests}/test_ignore.py (99%) rename {dulwich/tests => tests}/test_index.py (98%) rename {dulwich/tests => tests}/test_lfs.py (97%) rename {dulwich/tests => tests}/test_line_ending.py (98%) rename {dulwich/tests => tests}/test_lru_cache.py (99%) rename {dulwich/tests => tests}/test_mailmap.py (98%) rename {dulwich/tests => tests}/test_missing_obj_finder.py (98%) rename {dulwich/tests => tests}/test_object_store.py (99%) rename {dulwich/tests => tests}/test_objects.py (99%) rename {dulwich/tests => tests}/test_objectspec.py (98%) rename {dulwich/tests => tests}/test_pack.py (99%) rename {dulwich/tests => tests}/test_patch.py (99%) rename {dulwich/tests => tests}/test_porcelain.py (99%) rename {dulwich/tests => tests}/test_protocol.py (99%) rename {dulwich/tests => tests}/test_reflog.py (98%) rename {dulwich/tests => tests}/test_refs.py (99%) rename {dulwich/tests => tests}/test_repository.py (99%) rename {dulwich/tests => tests}/test_server.py (99%) rename {dulwich/tests => tests}/test_stash.py (94%) rename {dulwich/tests => tests}/test_utils.py (96%) rename {dulwich/tests => tests}/test_walk.py (98%) rename {dulwich/tests => tests}/test_web.py (98%) rename {dulwich/tests => tests}/utils.py (97%) diff --git a/.github/workflows/python-distributions.yml b/.github/workflows/python-distributions.yml index 09e198020..5dd4981b8 100644 --- a/.github/workflows/python-distributions.yml +++ b/.github/workflows/python-distributions.yml @@ -30,7 +30,7 @@ jobs: run: pip install -U gpg if: "matrix.os != 'windows-latest'" - name: Run test suite - run: python -m unittest dulwich.tests.test_suite + run: python -m unittest tests.test_suite - name: Set up QEMU uses: docker/setup-qemu-action@v3 if: "matrix.os == 'ubuntu-latest'" diff --git a/.github/workflows/pythontest.yml b/.github/workflows/pythontest.yml index 7686015fa..21d0fafca 100644 --- a/.github/workflows/pythontest.yml +++ b/.github/workflows/pythontest.yml @@ -54,4 +54,4 @@ jobs: - name: Coverage test suite run run: | pip install --upgrade coverage - python -m coverage run -p -m unittest dulwich.tests.test_suite + python -m coverage run -p -m unittest tests.test_suite diff --git a/.stestr.conf b/.stestr.conf index 64964357e..dfee9e5c5 100644 --- a/.stestr.conf +++ b/.stestr.conf @@ -1,2 +1,2 @@ [DEFAULT] -test_path=dulwich/tests +test_path=tests diff --git a/.testr.conf b/.testr.conf index 504386124..c2327f8f5 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,4 +1,4 @@ [DEFAULT] -test_command=PYTHONPATH=. python -m subunit.run $IDOPTION $LISTOPT dulwich.tests.test_suite +test_command=PYTHONPATH=. python3 -m subunit.run $IDOPTION $LISTOPT tests.test_suite test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/Makefile b/Makefile index aa937f428..3a4f1b22f 100644 --- a/Makefile +++ b/Makefile @@ -22,22 +22,22 @@ install:: $(SETUP) install --root="$(DESTDIR)" check:: build - $(RUNTEST) dulwich.tests.test_suite + $(RUNTEST) tests.test_suite check-tutorial:: build - $(RUNTEST) dulwich.tests.tutorial_test_suite + $(RUNTEST) tests.tutorial_test_suite check-nocompat:: build - $(RUNTEST) dulwich.tests.nocompat_test_suite + $(RUNTEST) tests.nocompat_test_suite check-compat:: build - $(RUNTEST) dulwich.tests.compat_test_suite + $(RUNTEST) tests.compat_test_suite check-pypy:: clean $(MAKE) check-noextensions PYTHON=pypy check-noextensions:: clean - $(RUNTEST) dulwich.tests.test_suite + $(RUNTEST) tests.test_suite check-contrib:: clean $(RUNTEST) -v dulwich.contrib.test_suite @@ -55,7 +55,7 @@ style: $(RUFF) check . coverage: - $(COVERAGE) run -m unittest dulwich.tests.test_suite dulwich.contrib.test_suite + $(COVERAGE) run -m unittest tests.test_suite dulwich.contrib.test_suite coverage-html: coverage $(COVERAGE) html diff --git a/NEWS b/NEWS index cd09f9a77..6e1c38f32 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ 0.21.8 UNRELEASED + * Move tests to root. (Jelmer Vernooij, #1024) + * Convert the optional C implementations to Rust. (Jelmer Vernooij) diff --git a/dulwich/contrib/README.swift.rst b/dulwich/contrib/README.swift.rst index 4976b90a3..c9a470801 100644 --- a/dulwich/contrib/README.swift.rst +++ b/dulwich/contrib/README.swift.rst @@ -56,7 +56,7 @@ How to start unittest There is no need to have a Swift cluster running to run the unitests. Just run the following command in the Dulwich source directory:: - $ PYTHONPATH=. python -m dulwich.contrib.test_swift + $ PYTHONPATH=. python -m tests.contrib.test_swift How to start functional tests ----------------------------- @@ -65,7 +65,7 @@ We provide some basic tests to perform smoke tests against a real Swift cluster. To run those functional tests you need a properly configured configuration file. The tests can be run as follow:: - $ DULWICH_SWIFT_CFG=/etc/swift-dul.conf PYTHONPATH=. python -m dulwich.contrib.test_swift_smoke + $ DULWICH_SWIFT_CFG=/etc/swift-dul.conf PYTHONPATH=. python -m tests.contrib.test_swift_smoke How to install -------------- diff --git a/dulwich/contrib/__init__.py b/dulwich/contrib/__init__.py index cc23d2af1..4a083036d 100644 --- a/dulwich/contrib/__init__.py +++ b/dulwich/contrib/__init__.py @@ -18,15 +18,3 @@ # License, Version 2.0. # - -def test_suite(): - import unittest - - names = [ - "paramiko_vendor", - "release_robot", - "swift", - ] - module_names = ["dulwich.contrib.test_" + name for name in names] - loader = unittest.TestLoader() - return loader.loadTestsFromNames(module_names) diff --git a/pyproject.toml b/pyproject.toml index 6592b8f7b..f0fe520e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,8 +54,6 @@ ignore_missing_imports = true packages = [ "dulwich", "dulwich.cloud", - "dulwich.tests", - "dulwich.tests.compat", "dulwich.contrib", ] include-package-data = true diff --git a/dulwich/tests/__init__.py b/tests/__init__.py similarity index 94% rename from dulwich/tests/__init__.py rename to tests/__init__.py index 7fe34f7a9..52d587dde 100644 --- a/dulwich/tests/__init__.py +++ b/tests/__init__.py @@ -150,7 +150,7 @@ def self_test_suite(): "walk", "web", ] - module_names = ["dulwich.tests.test_" + name for name in names] + module_names = ["tests.test_" + name for name in names] loader = unittest.TestLoader() return loader.loadTestsFromNames(module_names) @@ -164,7 +164,7 @@ def tutorial_test_suite(): "remote", "conclusion", ] - tutorial_files = [f"../../docs/tutorial/{name}.txt" for name in tutorial] + tutorial_files = [f"../docs/tutorial/{name}.txt" for name in tutorial] to_restore = [] @@ -196,7 +196,7 @@ def teardown(test): return doctest.DocFileSuite( module_relative=True, - package="dulwich.tests", + package="tests", setUp=setup, tearDown=teardown, *tutorial_files, @@ -215,7 +215,7 @@ def nocompat_test_suite(): def compat_test_suite(): result = unittest.TestSuite() - from dulwich.tests.compat import test_suite as compat_test_suite + from .compat import test_suite as compat_test_suite result.addTests(compat_test_suite()) return result @@ -226,10 +226,10 @@ def test_suite(): result.addTests(self_test_suite()) if sys.platform != "win32": result.addTests(tutorial_test_suite()) - from dulwich.tests.compat import test_suite as compat_test_suite + from .compat import test_suite as compat_test_suite result.addTests(compat_test_suite()) - from dulwich.contrib import test_suite as contrib_test_suite + from .contrib import test_suite as contrib_test_suite result.addTests(contrib_test_suite()) return result diff --git a/dulwich/tests/compat/__init__.py b/tests/compat/__init__.py similarity index 94% rename from dulwich/tests/compat/__init__.py rename to tests/compat/__init__.py index 24747775c..588937d5b 100644 --- a/dulwich/tests/compat/__init__.py +++ b/tests/compat/__init__.py @@ -34,7 +34,7 @@ def test_suite(): "utils", "web", ] - module_names = ["dulwich.tests.compat.test_" + name for name in names] + module_names = ["tests.compat.test_" + name for name in names] result = unittest.TestSuite() loader = unittest.TestLoader() suite = loader.loadTestsFromNames(module_names) diff --git a/dulwich/tests/compat/server_utils.py b/tests/compat/server_utils.py similarity index 98% rename from dulwich/tests/compat/server_utils.py rename to tests/compat/server_utils.py index 59a9beeaa..cd06126c0 100644 --- a/dulwich/tests/compat/server_utils.py +++ b/tests/compat/server_utils.py @@ -26,10 +26,11 @@ import socket import tempfile -from ...objects import hex_to_sha -from ...protocol import CAPABILITY_SIDE_BAND_64K -from ...repo import Repo -from ...server import ReceivePackHandler +from dulwich.objects import hex_to_sha +from dulwich.protocol import CAPABILITY_SIDE_BAND_64K +from dulwich.repo import Repo +from dulwich.server import ReceivePackHandler + from ..utils import tear_down_repo from .utils import require_git_version, run_git_or_fail diff --git a/dulwich/tests/compat/test_client.py b/tests/compat/test_client.py similarity index 99% rename from dulwich/tests/compat/test_client.py rename to tests/compat/test_client.py index cdc7dd993..e86d39282 100644 --- a/dulwich/tests/compat/test_client.py +++ b/tests/compat/test_client.py @@ -36,8 +36,8 @@ from urllib.parse import unquote from dulwich import client, file, index, objects, protocol, repo -from dulwich.tests import SkipTest, expectedFailure +from .. import SkipTest, expectedFailure from .utils import ( _DEFAULT_GIT, CompatTestCase, diff --git a/dulwich/tests/compat/test_pack.py b/tests/compat/test_pack.py similarity index 98% rename from dulwich/tests/compat/test_pack.py rename to tests/compat/test_pack.py index 351351a5d..d8b554d8a 100644 --- a/dulwich/tests/compat/test_pack.py +++ b/tests/compat/test_pack.py @@ -26,10 +26,10 @@ import shutil import tempfile -from dulwich.tests import SkipTest +from dulwich.objects import Blob +from dulwich.pack import write_pack -from ...objects import Blob -from ...pack import write_pack +from .. import SkipTest from ..test_pack import PackTests, a_sha, pack1_sha from .utils import require_git_version, run_git_or_fail diff --git a/dulwich/tests/compat/test_patch.py b/tests/compat/test_patch.py similarity index 99% rename from dulwich/tests/compat/test_patch.py rename to tests/compat/test_patch.py index aa33f0db7..31e155642 100644 --- a/dulwich/tests/compat/test_patch.py +++ b/tests/compat/test_patch.py @@ -26,8 +26,8 @@ from io import BytesIO from dulwich import porcelain +from dulwich.repo import Repo -from ...repo import Repo from .utils import CompatTestCase, run_git_or_fail diff --git a/dulwich/tests/compat/test_porcelain.py b/tests/compat/test_porcelain.py similarity index 100% rename from dulwich/tests/compat/test_porcelain.py rename to tests/compat/test_porcelain.py diff --git a/dulwich/tests/compat/test_repository.py b/tests/compat/test_repository.py similarity index 99% rename from dulwich/tests/compat/test_repository.py rename to tests/compat/test_repository.py index 3ab51a67e..a63bac7ad 100644 --- a/dulwich/tests/compat/test_repository.py +++ b/tests/compat/test_repository.py @@ -25,8 +25,9 @@ from io import BytesIO from itertools import chain -from ...objects import hex_to_sha -from ...repo import Repo, check_ref_format +from dulwich.objects import hex_to_sha +from dulwich.repo import Repo, check_ref_format + from .utils import CompatTestCase, require_git_version, rmtree_ro, run_git_or_fail diff --git a/dulwich/tests/compat/test_server.py b/tests/compat/test_server.py similarity index 97% rename from dulwich/tests/compat/test_server.py rename to tests/compat/test_server.py index 238fb3934..a518a1431 100644 --- a/dulwich/tests/compat/test_server.py +++ b/tests/compat/test_server.py @@ -29,9 +29,9 @@ import sys import threading -from dulwich.tests import skipIf +from dulwich.server import DictBackend, TCPGitServer -from ...server import DictBackend, TCPGitServer +from .. import skipIf from .server_utils import NoSideBand64kReceivePackHandler, ServerTests from .utils import CompatTestCase, require_git_version diff --git a/dulwich/tests/compat/test_utils.py b/tests/compat/test_utils.py similarity index 97% rename from dulwich/tests/compat/test_utils.py rename to tests/compat/test_utils.py index 65afe5a36..b172bb4a2 100644 --- a/dulwich/tests/compat/test_utils.py +++ b/tests/compat/test_utils.py @@ -20,8 +20,8 @@ """Tests for git compatibility utilities.""" -from dulwich.tests import SkipTest, TestCase -from dulwich.tests.compat import utils +from .. import SkipTest, TestCase +from . import utils class GitVersionTests(TestCase): diff --git a/dulwich/tests/compat/test_web.py b/tests/compat/test_web.py similarity index 98% rename from dulwich/tests/compat/test_web.py rename to tests/compat/test_web.py index ff53f642b..78f4e43ac 100644 --- a/dulwich/tests/compat/test_web.py +++ b/tests/compat/test_web.py @@ -30,15 +30,15 @@ from typing import Tuple from wsgiref import simple_server -from dulwich.tests import SkipTest, skipIf - -from ...server import DictBackend, ReceivePackHandler, UploadPackHandler -from ...web import ( +from dulwich.server import DictBackend, ReceivePackHandler, UploadPackHandler +from dulwich.web import ( HTTPGitApplication, WSGIRequestHandlerLogger, WSGIServerLogger, make_wsgi_chain, ) + +from .. import SkipTest, skipIf from .server_utils import NoSideBand64kReceivePackHandler, ServerTests from .utils import CompatTestCase diff --git a/dulwich/tests/compat/utils.py b/tests/compat/utils.py similarity index 97% rename from dulwich/tests/compat/utils.py rename to tests/compat/utils.py index d7c4a7b61..69cecedee 100644 --- a/dulwich/tests/compat/utils.py +++ b/tests/compat/utils.py @@ -32,16 +32,16 @@ import time from typing import Tuple -from dulwich.tests import SkipTest, TestCase +from dulwich.protocol import TCP_GIT_PORT +from dulwich.repo import Repo -from ...protocol import TCP_GIT_PORT -from ...repo import Repo +from .. import SkipTest, TestCase _DEFAULT_GIT = "git" _VERSION_LEN = 4 _REPOS_DATA_DIR = os.path.abspath( os.path.join( - os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "testdata", "repos" + os.path.dirname(__file__), os.pardir, os.pardir, "testdata", "repos" ) ) diff --git a/tests/contrib/__init__.py b/tests/contrib/__init__.py new file mode 100644 index 000000000..92b1e5b94 --- /dev/null +++ b/tests/contrib/__init__.py @@ -0,0 +1,31 @@ +# __init__.py -- Contrib module for Dulwich +# Copyright (C) 2014 Jelmer Vernooij +# +# Dulwich is dual-licensed under the Apache License, Version 2.0 and the GNU +# General Public License as public by the Free Software Foundation; version 2.0 +# or (at your option) any later version. You can redistribute it and/or +# modify it under the terms of either of these two licenses. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# You should have received a copy of the licenses; if not, see +# for a copy of the GNU General Public License +# and for a copy of the Apache +# License, Version 2.0. +# + +def test_suite(): + import unittest + + names = [ + "paramiko_vendor", + "release_robot", + "swift", + ] + module_names = ["tests.contrib.test_" + name for name in names] + loader = unittest.TestLoader() + return loader.loadTestsFromNames(module_names) diff --git a/dulwich/contrib/test_paramiko_vendor.py b/tests/contrib/test_paramiko_vendor.py similarity index 98% rename from dulwich/contrib/test_paramiko_vendor.py rename to tests/contrib/test_paramiko_vendor.py index 496987e20..0e12e5d77 100644 --- a/dulwich/contrib/test_paramiko_vendor.py +++ b/tests/contrib/test_paramiko_vendor.py @@ -24,7 +24,7 @@ from io import StringIO from unittest import skipIf -from dulwich.tests import TestCase +from .. import TestCase try: import paramiko @@ -32,7 +32,7 @@ has_paramiko = False else: has_paramiko = True - from .paramiko_vendor import ParamikoSSHVendor + from dulwich.contrib.paramiko_vendor import ParamikoSSHVendor class Server(paramiko.ServerInterface): """http://docs.paramiko.org/en/2.4/api/server.html.""" diff --git a/dulwich/contrib/test_release_robot.py b/tests/contrib/test_release_robot.py similarity index 98% rename from dulwich/contrib/test_release_robot.py rename to tests/contrib/test_release_robot.py index 7e8ed261b..4f6622b40 100644 --- a/dulwich/contrib/test_release_robot.py +++ b/tests/contrib/test_release_robot.py @@ -29,9 +29,9 @@ from typing import ClassVar, Dict, List, Optional, Tuple from dulwich.contrib import release_robot +from dulwich.repo import Repo -from ..repo import Repo -from ..tests.utils import make_commit, make_tag +from ..utils import make_commit, make_tag BASEDIR = os.path.abspath(os.path.dirname(__file__)) # this directory diff --git a/dulwich/contrib/test_swift.py b/tests/contrib/test_swift.py similarity index 99% rename from dulwich/contrib/test_swift.py rename to tests/contrib/test_swift.py index 32015c225..8608cecd1 100644 --- a/dulwich/contrib/test_swift.py +++ b/tests/contrib/test_swift.py @@ -28,10 +28,10 @@ from time import time from unittest import skipIf -from dulwich.tests import TestCase +from dulwich.objects import Blob, Commit, Tag, Tree, parse_timezone -from ..objects import Blob, Commit, Tag, Tree, parse_timezone -from ..tests.test_object_store import ObjectStoreTests +from .. import TestCase +from ..test_object_store import ObjectStoreTests missing_libs = [] diff --git a/dulwich/contrib/test_swift_smoke.py b/tests/contrib/test_swift_smoke.py similarity index 100% rename from dulwich/contrib/test_swift_smoke.py rename to tests/contrib/test_swift_smoke.py diff --git a/dulwich/tests/test_archive.py b/tests/test_archive.py similarity index 95% rename from dulwich/tests/test_archive.py rename to tests/test_archive.py index 0c84509df..a0a050886 100644 --- a/dulwich/tests/test_archive.py +++ b/tests/test_archive.py @@ -25,11 +25,11 @@ from io import BytesIO from unittest import skipUnless -from dulwich.tests import TestCase +from dulwich.archive import tar_stream +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob, Tree -from ..archive import tar_stream -from ..object_store import MemoryObjectStore -from ..objects import Blob, Tree +from . import TestCase from .utils import build_commit_graph try: diff --git a/dulwich/tests/test_blackbox.py b/tests/test_blackbox.py similarity index 97% rename from dulwich/tests/test_blackbox.py rename to tests/test_blackbox.py index 7041ce00d..34e2e47b1 100644 --- a/dulwich/tests/test_blackbox.py +++ b/tests/test_blackbox.py @@ -23,9 +23,9 @@ import shutil import tempfile -from dulwich.tests import BlackboxTestCase +from dulwich.repo import Repo -from ..repo import Repo +from . import BlackboxTestCase class GitReceivePackTests(BlackboxTestCase): diff --git a/dulwich/tests/test_bundle.py b/tests/test_bundle.py similarity index 92% rename from dulwich/tests/test_bundle.py rename to tests/test_bundle.py index 1f0cba2c8..d60d22272 100644 --- a/dulwich/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -24,10 +24,10 @@ import tempfile from io import BytesIO -from dulwich.tests import TestCase +from dulwich.bundle import Bundle, read_bundle, write_bundle +from dulwich.pack import PackData, write_pack_objects -from ..bundle import Bundle, read_bundle, write_bundle -from ..pack import PackData, write_pack_objects +from . import TestCase class BundleTests(TestCase): diff --git a/dulwich/tests/test_client.py b/tests/test_client.py similarity index 99% rename from dulwich/tests/test_client.py rename to tests/test_client.py index 72eebc3e3..3ada34992 100644 --- a/dulwich/tests/test_client.py +++ b/tests/test_client.py @@ -32,9 +32,7 @@ import dulwich from dulwich import client -from dulwich.tests import TestCase, skipIf - -from ..client import ( +from dulwich.client import ( FetchPackResult, GitProtocolError, HangupException, @@ -57,11 +55,13 @@ get_transport_and_path_from_url, parse_rsync_url, ) -from ..config import ConfigDict -from ..objects import Commit, Tree -from ..pack import pack_objects_to_data, write_pack_data, write_pack_objects -from ..protocol import TCP_GIT_PORT, Protocol -from ..repo import MemoryRepo, Repo +from dulwich.config import ConfigDict +from dulwich.objects import Commit, Tree +from dulwich.pack import pack_objects_to_data, write_pack_data, write_pack_objects +from dulwich.protocol import TCP_GIT_PORT, Protocol +from dulwich.repo import MemoryRepo, Repo + +from . import TestCase, skipIf from .utils import open_repo, setup_warning_catcher, tear_down_repo diff --git a/dulwich/tests/test_config.py b/tests/test_config.py similarity index 99% rename from dulwich/tests/test_config.py rename to tests/test_config.py index 7857bb134..dd985227b 100644 --- a/dulwich/tests/test_config.py +++ b/tests/test_config.py @@ -26,9 +26,7 @@ from unittest import skipIf from unittest.mock import patch -from dulwich.tests import TestCase - -from ..config import ( +from dulwich.config import ( ConfigDict, ConfigFile, StackedConfig, @@ -41,6 +39,8 @@ parse_submodules, ) +from . import TestCase + class ConfigFileTests(TestCase): def from_file(self, text): diff --git a/dulwich/tests/test_credentials.py b/tests/test_credentials.py similarity index 94% rename from dulwich/tests/test_credentials.py rename to tests/test_credentials.py index 3f06bef8b..a677d7d79 100644 --- a/dulwich/tests/test_credentials.py +++ b/tests/test_credentials.py @@ -21,10 +21,14 @@ from urllib.parse import urlparse -from dulwich.tests import TestCase +from dulwich.config import ConfigDict +from dulwich.credentials import ( + match_partial_url, + match_urls, + urlmatch_credential_sections, +) -from ..config import ConfigDict -from ..credentials import match_partial_url, match_urls, urlmatch_credential_sections +from . import TestCase class TestCredentialHelpersUtils(TestCase): diff --git a/dulwich/tests/test_diff_tree.py b/tests/test_diff_tree.py similarity index 99% rename from dulwich/tests/test_diff_tree.py rename to tests/test_diff_tree.py index 63dc8fcd4..04c83d053 100644 --- a/dulwich/tests/test_diff_tree.py +++ b/tests/test_diff_tree.py @@ -22,9 +22,7 @@ from itertools import permutations -from dulwich.tests import TestCase - -from ..diff_tree import ( +from dulwich.diff_tree import ( CHANGE_COPY, CHANGE_MODIFY, CHANGE_RENAME, @@ -42,9 +40,11 @@ tree_changes, tree_changes_for_merge, ) -from ..index import commit_tree -from ..object_store import MemoryObjectStore -from ..objects import Blob, ShaFile, Tree, TreeEntry +from dulwich.index import commit_tree +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob, ShaFile, Tree, TreeEntry + +from . import TestCase from .utils import F, ext_functest_builder, functest_builder, make_object diff --git a/dulwich/tests/test_fastexport.py b/tests/test_fastexport.py similarity index 97% rename from dulwich/tests/test_fastexport.py rename to tests/test_fastexport.py index 982723405..5076f7767 100644 --- a/dulwich/tests/test_fastexport.py +++ b/tests/test_fastexport.py @@ -21,11 +21,11 @@ import stat from io import BytesIO -from dulwich.tests import SkipTest, TestCase +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import ZERO_SHA, Blob, Commit, Tree +from dulwich.repo import MemoryRepo -from ..object_store import MemoryObjectStore -from ..objects import ZERO_SHA, Blob, Commit, Tree -from ..repo import MemoryRepo +from . import SkipTest, TestCase from .utils import build_commit_graph @@ -37,7 +37,7 @@ def setUp(self): self.store = MemoryObjectStore() self.stream = BytesIO() try: - from ..fastexport import GitFastExporter + from dulwich.fastexport import GitFastExporter except ImportError as exc: raise SkipTest("python-fastimport not available") from exc self.fastexporter = GitFastExporter(self.stream, self.store) @@ -85,7 +85,7 @@ def setUp(self): super().setUp() self.repo = MemoryRepo() try: - from ..fastexport import GitImportProcessor + from dulwich.fastexport import GitImportProcessor except ImportError as exc: raise SkipTest("python-fastimport not available") from exc self.processor = GitImportProcessor(self.repo) diff --git a/dulwich/tests/test_file.py b/tests/test_file.py similarity index 98% rename from dulwich/tests/test_file.py rename to tests/test_file.py index 6c1c19d4f..482fb023f 100644 --- a/dulwich/tests/test_file.py +++ b/tests/test_file.py @@ -24,9 +24,9 @@ import sys import tempfile -from dulwich.tests import SkipTest, TestCase +from dulwich.file import FileLocked, GitFile, _fancy_rename -from ..file import FileLocked, GitFile, _fancy_rename +from . import SkipTest, TestCase class FancyRenameTests(TestCase): diff --git a/dulwich/tests/test_grafts.py b/tests/test_grafts.py similarity index 97% rename from dulwich/tests/test_grafts.py rename to tests/test_grafts.py index 661ad3101..f345391b0 100644 --- a/dulwich/tests/test_grafts.py +++ b/tests/test_grafts.py @@ -23,11 +23,11 @@ import shutil import tempfile -from dulwich.tests import TestCase +from dulwich.errors import ObjectFormatException +from dulwich.objects import Tree +from dulwich.repo import MemoryRepo, Repo, parse_graftpoints, serialize_graftpoints -from ..errors import ObjectFormatException -from ..objects import Tree -from ..repo import MemoryRepo, Repo, parse_graftpoints, serialize_graftpoints +from . import TestCase def makesha(digit): diff --git a/dulwich/tests/test_graph.py b/tests/test_graph.py similarity index 98% rename from dulwich/tests/test_graph.py rename to tests/test_graph.py index 08e00c6a7..0d14b5e35 100644 --- a/dulwich/tests/test_graph.py +++ b/tests/test_graph.py @@ -19,10 +19,10 @@ """Tests for dulwich.graph.""" -from dulwich.tests import TestCase +from dulwich.graph import WorkList, _find_lcas, can_fast_forward +from dulwich.repo import MemoryRepo -from ..graph import WorkList, _find_lcas, can_fast_forward -from ..repo import MemoryRepo +from . import TestCase from .utils import make_commit diff --git a/dulwich/tests/test_greenthreads.py b/tests/test_greenthreads.py similarity index 95% rename from dulwich/tests/test_greenthreads.py rename to tests/test_greenthreads.py index 3581f2b53..40e33c9d9 100644 --- a/dulwich/tests/test_greenthreads.py +++ b/tests/test_greenthreads.py @@ -22,10 +22,10 @@ import time -from dulwich.tests import TestCase, skipIf +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob, Commit, Tree, parse_timezone -from ..object_store import MemoryObjectStore -from ..objects import Blob, Commit, Tree, parse_timezone +from . import TestCase, skipIf try: import gevent # noqa: F401 diff --git a/dulwich/tests/test_hooks.py b/tests/test_hooks.py similarity index 97% rename from dulwich/tests/test_hooks.py rename to tests/test_hooks.py index 34517cc54..965c98925 100644 --- a/dulwich/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -26,9 +26,9 @@ import tempfile from dulwich import errors -from dulwich.tests import TestCase +from dulwich.hooks import CommitMsgShellHook, PostCommitShellHook, PreCommitShellHook -from ..hooks import CommitMsgShellHook, PostCommitShellHook, PreCommitShellHook +from . import TestCase class ShellHookTests(TestCase): diff --git a/dulwich/tests/test_ignore.py b/tests/test_ignore.py similarity index 99% rename from dulwich/tests/test_ignore.py rename to tests/test_ignore.py index f9b6b6025..d051d1d46 100644 --- a/dulwich/tests/test_ignore.py +++ b/tests/test_ignore.py @@ -26,9 +26,7 @@ import tempfile from io import BytesIO -from dulwich.tests import TestCase - -from ..ignore import ( +from dulwich.ignore import ( IgnoreFilter, IgnoreFilterManager, IgnoreFilterStack, @@ -37,7 +35,9 @@ read_ignore_patterns, translate, ) -from ..repo import Repo +from dulwich.repo import Repo + +from . import TestCase POSITIVE_MATCH_TESTS = [ (b"foo.c", b"*.c"), diff --git a/dulwich/tests/test_index.py b/tests/test_index.py similarity index 98% rename from dulwich/tests/test_index.py rename to tests/test_index.py index 28c041dc3..7768773cd 100644 --- a/dulwich/tests/test_index.py +++ b/tests/test_index.py @@ -28,9 +28,7 @@ import tempfile from io import BytesIO -from dulwich.tests import TestCase, skipIf - -from ..index import ( +from dulwich.index import ( Index, IndexEntry, SerializedIndexEntry, @@ -49,9 +47,11 @@ write_index, write_index_dict, ) -from ..object_store import MemoryObjectStore -from ..objects import S_IFGITLINK, Blob, Commit, Tree -from ..repo import Repo +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import S_IFGITLINK, Blob, Commit, Tree +from dulwich.repo import Repo + +from . import TestCase, skipIf def can_symlink(): @@ -70,7 +70,7 @@ def can_symlink(): class IndexTestCase(TestCase): - datadir = os.path.join(os.path.dirname(__file__), "../../testdata/indexes") + datadir = os.path.join(os.path.dirname(__file__), "../testdata/indexes") def get_simple_index(self, name): return Index(os.path.join(self.datadir, name)) diff --git a/dulwich/tests/test_lfs.py b/tests/test_lfs.py similarity index 97% rename from dulwich/tests/test_lfs.py rename to tests/test_lfs.py index f27206846..484b666d8 100644 --- a/dulwich/tests/test_lfs.py +++ b/tests/test_lfs.py @@ -23,7 +23,8 @@ import shutil import tempfile -from ..lfs import LFSStore +from dulwich.lfs import LFSStore + from . import TestCase diff --git a/dulwich/tests/test_line_ending.py b/tests/test_line_ending.py similarity index 98% rename from dulwich/tests/test_line_ending.py rename to tests/test_line_ending.py index 9eb2a1cf9..79254ebda 100644 --- a/dulwich/tests/test_line_ending.py +++ b/tests/test_line_ending.py @@ -20,16 +20,16 @@ """Tests for the line ending conversion.""" -from dulwich.tests import TestCase - -from ..line_ending import ( +from dulwich.line_ending import ( convert_crlf_to_lf, convert_lf_to_crlf, get_checkin_filter_autocrlf, get_checkout_filter_autocrlf, normalize_blob, ) -from ..objects import Blob +from dulwich.objects import Blob + +from . import TestCase class LineEndingConversion(TestCase): diff --git a/dulwich/tests/test_lru_cache.py b/tests/test_lru_cache.py similarity index 99% rename from dulwich/tests/test_lru_cache.py rename to tests/test_lru_cache.py index d15b15d50..343892c76 100644 --- a/dulwich/tests/test_lru_cache.py +++ b/tests/test_lru_cache.py @@ -20,7 +20,8 @@ """Tests for the lru_cache module.""" from dulwich import lru_cache -from dulwich.tests import TestCase + +from . import TestCase class TestLRUCache(TestCase): diff --git a/dulwich/tests/test_mailmap.py b/tests/test_mailmap.py similarity index 98% rename from dulwich/tests/test_mailmap.py rename to tests/test_mailmap.py index bbb392f16..08a882a50 100644 --- a/dulwich/tests/test_mailmap.py +++ b/tests/test_mailmap.py @@ -23,7 +23,7 @@ from io import BytesIO from unittest import TestCase -from ..mailmap import Mailmap, read_mailmap +from dulwich.mailmap import Mailmap, read_mailmap class ReadMailmapTests(TestCase): diff --git a/dulwich/tests/test_missing_obj_finder.py b/tests/test_missing_obj_finder.py similarity index 98% rename from dulwich/tests/test_missing_obj_finder.py rename to tests/test_missing_obj_finder.py index f11b205b1..7a6b79b52 100644 --- a/dulwich/tests/test_missing_obj_finder.py +++ b/tests/test_missing_obj_finder.py @@ -18,10 +18,10 @@ # License, Version 2.0. # -from dulwich.tests import TestCase +from dulwich.object_store import MemoryObjectStore, MissingObjectFinder +from dulwich.objects import Blob -from ..object_store import MemoryObjectStore, MissingObjectFinder -from ..objects import Blob +from . import TestCase from .utils import build_commit_graph, make_object, make_tag diff --git a/dulwich/tests/test_object_store.py b/tests/test_object_store.py similarity index 99% rename from dulwich/tests/test_object_store.py rename to tests/test_object_store.py index fc026082f..b9d78e8aa 100644 --- a/dulwich/tests/test_object_store.py +++ b/tests/test_object_store.py @@ -29,11 +29,9 @@ from io import BytesIO from unittest import skipUnless -from dulwich.tests import TestCase - -from ..errors import NotTreeError -from ..index import commit_tree -from ..object_store import ( +from dulwich.errors import NotTreeError +from dulwich.index import commit_tree +from dulwich.object_store import ( DiskObjectStore, MemoryObjectStore, ObjectStoreGraphWalker, @@ -44,7 +42,7 @@ read_packs_file, tree_lookup_path, ) -from ..objects import ( +from dulwich.objects import ( S_IFGITLINK, Blob, EmptyFileException, @@ -53,8 +51,10 @@ TreeEntry, sha_to_hex, ) -from ..pack import REF_DELTA, write_pack_objects -from ..protocol import DEPTH_INFINITE +from dulwich.pack import REF_DELTA, write_pack_objects +from dulwich.protocol import DEPTH_INFINITE + +from . import TestCase from .utils import build_pack, make_object, make_tag try: diff --git a/dulwich/tests/test_objects.py b/tests/test_objects.py similarity index 99% rename from dulwich/tests/test_objects.py rename to tests/test_objects.py index 8b8b5b5e6..9c4874bf5 100644 --- a/dulwich/tests/test_objects.py +++ b/tests/test_objects.py @@ -29,10 +29,8 @@ from io import BytesIO from itertools import permutations -from dulwich.tests import TestCase - -from ..errors import ObjectFormatException -from ..objects import ( +from dulwich.errors import ObjectFormatException +from dulwich.objects import ( MAX_TIME, Blob, Commit, @@ -54,6 +52,8 @@ sha_to_hex, sorted_tree_items, ) + +from . import TestCase from .utils import ext_functest_builder, functest_builder, make_commit, make_object a_sha = b"6f670c0fb53f9463760b7295fbb814e965fb20c8" @@ -75,7 +75,7 @@ class BlobReadTests(TestCase): """Test decompression of blobs.""" def get_sha_file(self, cls, base, sha): - dir = os.path.join(os.path.dirname(__file__), "..", "..", "testdata", base) + dir = os.path.join(os.path.dirname(__file__), "..", "testdata", base) return cls.from_path(hex_to_filename(dir, sha)) def get_blob(self, sha): @@ -855,7 +855,7 @@ def test_tree_items_dir_sort(self): self.assertEqual(_SORTED_TREE_ITEMS, x.items()) def _do_test_parse_tree(self, parse_tree): - dir = os.path.join(os.path.dirname(__file__), "..", "..", "testdata", "trees") + dir = os.path.join(os.path.dirname(__file__), "..", "testdata", "trees") o = Tree.from_path(hex_to_filename(dir, tree_sha)) self.assertEqual( [(b"a", 0o100644, a_sha), (b"b", 0o100644, b_sha)], diff --git a/dulwich/tests/test_objectspec.py b/tests/test_objectspec.py similarity index 98% rename from dulwich/tests/test_objectspec.py rename to tests/test_objectspec.py index 0e3476e55..185c1fe9b 100644 --- a/dulwich/tests/test_objectspec.py +++ b/tests/test_objectspec.py @@ -22,10 +22,8 @@ # TODO: Round-trip parse-serialize-parse and serialize-parse-serialize tests. -from dulwich.tests import TestCase - -from ..objects import Blob -from ..objectspec import ( +from dulwich.objects import Blob +from dulwich.objectspec import ( parse_commit, parse_commit_range, parse_object, @@ -35,7 +33,9 @@ parse_reftuples, parse_tree, ) -from ..repo import MemoryRepo +from dulwich.repo import MemoryRepo + +from . import TestCase from .utils import build_commit_graph diff --git a/dulwich/tests/test_pack.py b/tests/test_pack.py similarity index 99% rename from dulwich/tests/test_pack.py rename to tests/test_pack.py index d8fa4c1e3..c79665704 100644 --- a/dulwich/tests/test_pack.py +++ b/tests/test_pack.py @@ -30,13 +30,11 @@ from io import BytesIO from typing import Set -from dulwich.tests import TestCase - -from ..errors import ApplyDeltaError, ChecksumMismatch -from ..file import GitFile -from ..object_store import MemoryObjectStore -from ..objects import Blob, Commit, Tree, hex_to_sha, sha_to_hex -from ..pack import ( +from dulwich.errors import ApplyDeltaError, ChecksumMismatch +from dulwich.file import GitFile +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob, Commit, Tree, hex_to_sha, sha_to_hex +from dulwich.pack import ( OFS_DELTA, REF_DELTA, DeltaChainIterator, @@ -61,6 +59,8 @@ write_pack_index_v2, write_pack_object, ) + +from . import TestCase from .utils import build_pack, make_object pack1_sha = b"bc63ddad95e7321ee734ea11a7a62d314e0d7481" @@ -80,7 +80,7 @@ def setUp(self): self.addCleanup(shutil.rmtree, self.tempdir) datadir = os.path.abspath( - os.path.join(os.path.dirname(__file__), "../../testdata/packs") + os.path.join(os.path.dirname(__file__), "../testdata/packs") ) def get_pack_index(self, sha): diff --git a/dulwich/tests/test_patch.py b/tests/test_patch.py similarity index 99% rename from dulwich/tests/test_patch.py rename to tests/test_patch.py index 3653f7fbb..35e90d95d 100644 --- a/dulwich/tests/test_patch.py +++ b/tests/test_patch.py @@ -22,11 +22,9 @@ from io import BytesIO, StringIO -from dulwich.tests import SkipTest, TestCase - -from ..object_store import MemoryObjectStore -from ..objects import S_IFGITLINK, Blob, Commit, Tree -from ..patch import ( +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import S_IFGITLINK, Blob, Commit, Tree +from dulwich.patch import ( get_summary, git_am_patch_split, write_blob_diff, @@ -35,6 +33,8 @@ write_tree_diff, ) +from . import SkipTest, TestCase + class WriteCommitPatchTests(TestCase): def test_simple_bytesio(self): diff --git a/dulwich/tests/test_porcelain.py b/tests/test_porcelain.py similarity index 99% rename from dulwich/tests/test_porcelain.py rename to tests/test_porcelain.py index a0a6c6b0b..7a1c26f38 100644 --- a/dulwich/tests/test_porcelain.py +++ b/tests/test_porcelain.py @@ -36,15 +36,15 @@ from unittest import skipIf from dulwich import porcelain -from dulwich.tests import TestCase - -from ..diff_tree import tree_changes -from ..errors import CommitError -from ..objects import ZERO_SHA, Blob, Tag, Tree -from ..porcelain import CheckoutError -from ..repo import NoIndexPresent, Repo -from ..server import DictBackend -from ..web import make_server, make_wsgi_chain +from dulwich.diff_tree import tree_changes +from dulwich.errors import CommitError +from dulwich.objects import ZERO_SHA, Blob, Tag, Tree +from dulwich.porcelain import CheckoutError +from dulwich.repo import NoIndexPresent, Repo +from dulwich.server import DictBackend +from dulwich.web import make_server, make_wsgi_chain + +from . import TestCase from .utils import build_commit_graph, make_commit, make_object try: diff --git a/dulwich/tests/test_protocol.py b/tests/test_protocol.py similarity index 99% rename from dulwich/tests/test_protocol.py rename to tests/test_protocol.py index 3d12d1835..75c541176 100644 --- a/dulwich/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -22,10 +22,8 @@ from io import BytesIO -from dulwich.tests import TestCase - -from ..errors import HangupException -from ..protocol import ( +from dulwich.errors import HangupException +from dulwich.protocol import ( MULTI_ACK, MULTI_ACK_DETAILED, SINGLE_ACK, @@ -39,6 +37,8 @@ extract_want_line_capabilities, ) +from . import TestCase + class BaseProtocolTests: def test_write_pkt_line_none(self): diff --git a/dulwich/tests/test_reflog.py b/tests/test_reflog.py similarity index 98% rename from dulwich/tests/test_reflog.py rename to tests/test_reflog.py index fd0e7d33f..a8b4cf92e 100644 --- a/dulwich/tests/test_reflog.py +++ b/tests/test_reflog.py @@ -22,16 +22,16 @@ from io import BytesIO -from dulwich.tests import TestCase - -from ..objects import ZERO_SHA -from ..reflog import ( +from dulwich.objects import ZERO_SHA +from dulwich.reflog import ( drop_reflog_entry, format_reflog_line, parse_reflog_line, read_reflog, ) +from . import TestCase + class ReflogLineTests(TestCase): def test_format(self): diff --git a/dulwich/tests/test_refs.py b/tests/test_refs.py similarity index 99% rename from dulwich/tests/test_refs.py rename to tests/test_refs.py index 21f6bb87f..31e3e3725 100644 --- a/dulwich/tests/test_refs.py +++ b/tests/test_refs.py @@ -27,11 +27,9 @@ from typing import ClassVar, Dict from dulwich import errors -from dulwich.tests import SkipTest, TestCase - -from ..file import GitFile -from ..objects import ZERO_SHA -from ..refs import ( +from dulwich.file import GitFile +from dulwich.objects import ZERO_SHA +from dulwich.refs import ( DictRefsContainer, InfoRefsContainer, SymrefLoop, @@ -43,7 +41,9 @@ strip_peeled_refs, write_packed_refs, ) -from ..repo import Repo +from dulwich.repo import Repo + +from . import SkipTest, TestCase from .utils import open_repo, tear_down_repo diff --git a/dulwich/tests/test_repository.py b/tests/test_repository.py similarity index 99% rename from dulwich/tests/test_repository.py rename to tests/test_repository.py index a2d11802a..80605d1b7 100644 --- a/dulwich/tests/test_repository.py +++ b/tests/test_repository.py @@ -30,12 +30,10 @@ import warnings from dulwich import errors, objects, porcelain -from dulwich.tests import TestCase, skipIf - -from ..config import Config -from ..errors import NotGitRepository -from ..object_store import tree_lookup_path -from ..repo import ( +from dulwich.config import Config +from dulwich.errors import NotGitRepository +from dulwich.object_store import tree_lookup_path +from dulwich.repo import ( InvalidUserIdentity, MemoryRepo, Repo, @@ -43,6 +41,8 @@ UnsupportedVersion, check_user_identity, ) + +from . import TestCase, skipIf from .utils import open_repo, setup_warning_catcher, tear_down_repo missing_sha = b"b91fa4d900e17e99b433218e988c4eb4a3e9a097" @@ -406,7 +406,7 @@ def test_clone_no_head(self): temp_dir = self.mkdtemp() self.addCleanup(shutil.rmtree, temp_dir) repo_dir = os.path.join( - os.path.dirname(__file__), "..", "..", "testdata", "repos" + os.path.dirname(__file__), "..", "testdata", "repos" ) dest_dir = os.path.join(temp_dir, "a.git") shutil.copytree(os.path.join(repo_dir, "a.git"), dest_dir, symlinks=True) diff --git a/dulwich/tests/test_server.py b/tests/test_server.py similarity index 99% rename from dulwich/tests/test_server.py rename to tests/test_server.py index ccbe09029..2fe005ccd 100644 --- a/dulwich/tests/test_server.py +++ b/tests/test_server.py @@ -27,19 +27,17 @@ from io import BytesIO from typing import Dict, List -from dulwich.tests import TestCase - -from ..errors import ( +from dulwich.errors import ( GitProtocolError, HangupException, NotGitRepository, UnexpectedCommandError, ) -from ..object_store import MemoryObjectStore -from ..objects import Tree -from ..protocol import ZERO_SHA, format_capability_line -from ..repo import MemoryRepo, Repo -from ..server import ( +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Tree +from dulwich.protocol import ZERO_SHA, format_capability_line +from dulwich.repo import MemoryRepo, Repo +from dulwich.server import ( Backend, DictBackend, FileSystemBackend, @@ -55,6 +53,8 @@ serve_command, update_server_info, ) + +from . import TestCase from .utils import make_commit, make_tag ONE = b"1" * 40 diff --git a/dulwich/tests/test_stash.py b/tests/test_stash.py similarity index 94% rename from dulwich/tests/test_stash.py rename to tests/test_stash.py index d1e18db22..2bd3b7c4a 100644 --- a/dulwich/tests/test_stash.py +++ b/tests/test_stash.py @@ -20,8 +20,9 @@ """Tests for stashes.""" -from ..repo import MemoryRepo -from ..stash import Stash +from dulwich.repo import MemoryRepo +from dulwich.stash import Stash + from . import TestCase diff --git a/dulwich/tests/test_utils.py b/tests/test_utils.py similarity index 96% rename from dulwich/tests/test_utils.py rename to tests/test_utils.py index 5760ef5ce..e1814e94f 100644 --- a/dulwich/tests/test_utils.py +++ b/tests/test_utils.py @@ -20,10 +20,10 @@ """Tests for git test utilities.""" -from dulwich.tests import TestCase +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob -from ..object_store import MemoryObjectStore -from ..objects import Blob +from . import TestCase from .utils import build_commit_graph, make_object diff --git a/dulwich/tests/test_walk.py b/tests/test_walk.py similarity index 98% rename from dulwich/tests/test_walk.py rename to tests/test_walk.py index 6acf80b9a..79650c423 100644 --- a/dulwich/tests/test_walk.py +++ b/tests/test_walk.py @@ -23,13 +23,13 @@ from itertools import permutations from unittest import expectedFailure -from dulwich.tests import TestCase +from dulwich.diff_tree import CHANGE_MODIFY, CHANGE_RENAME, RenameDetector, TreeChange +from dulwich.errors import MissingCommitError +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob, Commit +from dulwich.walk import ORDER_TOPO, WalkEntry, Walker, _topo_reorder -from ..diff_tree import CHANGE_MODIFY, CHANGE_RENAME, RenameDetector, TreeChange -from ..errors import MissingCommitError -from ..object_store import MemoryObjectStore -from ..objects import Blob, Commit -from ..walk import ORDER_TOPO, WalkEntry, Walker, _topo_reorder +from . import TestCase from .utils import F, build_commit_graph, make_object, make_tag diff --git a/dulwich/tests/test_web.py b/tests/test_web.py similarity index 98% rename from dulwich/tests/test_web.py rename to tests/test_web.py index 223537c9d..d3ea62d60 100644 --- a/dulwich/tests/test_web.py +++ b/tests/test_web.py @@ -26,13 +26,11 @@ from io import BytesIO from typing import Type -from dulwich.tests import TestCase - -from ..object_store import MemoryObjectStore -from ..objects import Blob -from ..repo import BaseRepo, MemoryRepo -from ..server import DictBackend -from ..web import ( +from dulwich.object_store import MemoryObjectStore +from dulwich.objects import Blob +from dulwich.repo import BaseRepo, MemoryRepo +from dulwich.server import DictBackend +from dulwich.web import ( HTTP_ERROR, HTTP_FORBIDDEN, HTTP_NOT_FOUND, @@ -50,6 +48,8 @@ handle_service_request, send_file, ) + +from . import TestCase from .utils import make_object, make_tag diff --git a/dulwich/tests/utils.py b/tests/utils.py similarity index 97% rename from dulwich/tests/utils.py rename to tests/utils.py index 22f528645..13fe5a454 100644 --- a/dulwich/tests/utils.py +++ b/tests/utils.py @@ -28,11 +28,9 @@ import types import warnings -from dulwich.tests import SkipTest - -from ..index import commit_tree -from ..objects import Commit, FixedSha, Tag, object_class -from ..pack import ( +from dulwich.index import commit_tree +from dulwich.objects import Commit, FixedSha, Tag, object_class +from dulwich.pack import ( DELTA_TYPES, OFS_DELTA, REF_DELTA, @@ -42,7 +40,9 @@ write_pack_header, write_pack_object, ) -from ..repo import Repo +from dulwich.repo import Repo + +from . import SkipTest # Plain files are very frequently used in tests, so let the mode be very short. F = 0o100644 # Shorthand mode for Files. @@ -65,7 +65,7 @@ def open_repo(name, temp_dir=None): if temp_dir is None: temp_dir = tempfile.mkdtemp() repo_dir = os.path.join( - os.path.dirname(__file__), "..", "..", "testdata", "repos", name + os.path.dirname(__file__), "..", "testdata", "repos", name ) temp_repo_dir = os.path.join(temp_dir, name) shutil.copytree(repo_dir, temp_repo_dir, symlinks=True)