Skip to content

Commit

Permalink
Move tests to root. Fixes #1024
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Apr 13, 2024
1 parent ee02234 commit 245331a
Show file tree
Hide file tree
Showing 62 changed files with 256 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-distributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythontest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .stestr.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[DEFAULT]
test_path=dulwich/tests
test_path=tests
2 changes: 1 addition & 1 deletion .testr.conf
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
0.21.8 UNRELEASED

* Move tests to root. (Jelmer Vernooij, #1024)

* Convert the optional C implementations to Rust.
(Jelmer Vernooij)

Expand Down
4 changes: 2 additions & 2 deletions dulwich/contrib/README.swift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------------
Expand All @@ -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
--------------
Expand Down
12 changes: 0 additions & 12 deletions dulwich/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ ignore_missing_imports = true
packages = [
"dulwich",
"dulwich.cloud",
"dulwich.tests",
"dulwich.tests.compat",
"dulwich.contrib",
]
include-package-data = true
Expand Down
12 changes: 6 additions & 6 deletions dulwich/tests/__init__.py → tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 = []

Expand Down Expand Up @@ -196,7 +196,7 @@ def teardown(test):

return doctest.DocFileSuite(
module_relative=True,
package="dulwich.tests",
package="tests",
setUp=setup,
tearDown=teardown,
*tutorial_files,
Expand All @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions dulwich/tests/compat/test_web.py → tests/compat/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions dulwich/tests/compat/utils.py → tests/compat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)

Expand Down
31 changes: 31 additions & 0 deletions tests/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# __init__.py -- Contrib module for Dulwich
# Copyright (C) 2014 Jelmer Vernooij <[email protected]>
#
# 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
# <http://www.gnu.org/licenses/> for a copy of the GNU General Public License
# and <http://www.apache.org/licenses/LICENSE-2.0> 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)
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
from io import StringIO
from unittest import skipIf

from dulwich.tests import TestCase
from .. import TestCase

try:
import paramiko
except ImportError:
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."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions dulwich/contrib/test_swift.py → tests/contrib/test_swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions dulwich/tests/test_archive.py → tests/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 245331a

Please sign in to comment.