diff --git a/src/borg/conftest.py b/src/borg/conftest.py index 176003816..e9a749c1f 100644 --- a/src/borg/conftest.py +++ b/src/borg/conftest.py @@ -14,7 +14,7 @@ from borg.archiver import Archiver # noqa: E402 from borg.testsuite import has_lchflags, has_llfuse, has_pyfuse3 # noqa: E402 from borg.testsuite import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported # noqa: E402 from borg.testsuite.archiver import BORG_EXES -from borg.testsuite.platform_test import fakeroot_detected # noqa: E402 +from borg.testsuite.platform.platform_test import fakeroot_detected # noqa: E402 @pytest.fixture(autouse=True) diff --git a/src/borg/selftest.py b/src/borg/selftest.py index 0acbee19f..3a08d5be8 100644 --- a/src/borg/selftest.py +++ b/src/borg/selftest.py @@ -21,7 +21,7 @@ import sys import time from unittest import TestResult, TestSuite, defaultTestLoader -from .testsuite.crypto_test import CryptoTestCase +from .testsuite.crypto.crypto_test import CryptoTestCase from .testsuite.chunkers.buzhash_self_test import ChunkerTestCase from .testsuite.chunkers.fixed_self_test import ChunkerFixedTestCase diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py index c3620a50b..180f1f013 100644 --- a/src/borg/testsuite/archiver/__init__.py +++ b/src/borg/testsuite/archiver/__init__.py @@ -29,7 +29,7 @@ from ...repository import Repository from .. import has_lchflags, is_utime_fully_supported, have_fuse_mtime_ns, st_mtime_ns_round, no_selinux from .. import changedir from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported -from ..platform_test import is_win32 +from ..platform.platform_test import is_win32 from ...xattr import get_all RK_ENCRYPTION = "--encryption=repokey-aes-ocb" diff --git a/src/borg/testsuite/archiver/key_cmds_test.py b/src/borg/testsuite/archiver/key_cmds_test.py index 79d933f22..173d92a1f 100644 --- a/src/borg/testsuite/archiver/key_cmds_test.py +++ b/src/borg/testsuite/archiver/key_cmds_test.py @@ -10,7 +10,7 @@ from ...helpers import CommandError from ...helpers import bin_to_hex, hex_to_bin from ...helpers import msgpack from ...repository import Repository -from ..key_test import TestKey +from ..crypto.key_test import TestKey from . import RK_ENCRYPTION, KF_ENCRYPTION, cmd, _extract_repository_id, _set_repository_id, generate_archiver_tests pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA diff --git a/src/borg/testsuite/archiver/mount_cmds_test.py b/src/borg/testsuite/archiver/mount_cmds_test.py index 59dcda11b..45623af1e 100644 --- a/src/borg/testsuite/archiver/mount_cmds_test.py +++ b/src/borg/testsuite/archiver/mount_cmds_test.py @@ -12,7 +12,7 @@ from ...helpers import flags_noatime, flags_normal from .. import has_lchflags, llfuse from .. import changedir, no_selinux, same_ts_ns from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported -from ..platform_test import fakeroot_detected +from ..platform.platform_test import fakeroot_detected from . import RK_ENCRYPTION, cmd, assert_dirs_equal, create_regular_file, create_src_archive, open_archive, src_file from . import requires_hardlinks, _extract_hardlinks_setup, fuse_mount, create_test_files, generate_archiver_tests diff --git a/src/borg/testsuite/archiver/transfer_cmd_test.py b/src/borg/testsuite/archiver/transfer_cmd_test.py index 7ac3df4bd..39d570d76 100644 --- a/src/borg/testsuite/archiver/transfer_cmd_test.py +++ b/src/borg/testsuite/archiver/transfer_cmd_test.py @@ -13,7 +13,7 @@ from ...constants import * # NOQA from ...helpers import open_item from ...helpers.time import parse_timestamp from ...helpers.parseformat import parse_file_size, ChunkerParams -from ..platform_test import is_win32 +from ..platform.platform_test import is_win32 from . import cmd, create_regular_file, create_test_files, RK_ENCRYPTION, open_archive, generate_archiver_tests pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote") # NOQA diff --git a/src/borg/testsuite/cache_test.py b/src/borg/testsuite/cache_test.py index e65735459..e6a5092ff 100644 --- a/src/borg/testsuite/cache_test.py +++ b/src/borg/testsuite/cache_test.py @@ -3,7 +3,7 @@ import os import pytest from .hashindex_test import H -from .key_test import TestKey +from .crypto.key_test import TestKey from ..archive import Statistics from ..cache import AdHocWithFilesCache from ..crypto.key import AESOCBRepoKey diff --git a/src/borg/testsuite/crypto/__init__.py b/src/borg/testsuite/crypto/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/borg/testsuite/crypto_test.py b/src/borg/testsuite/crypto/crypto_test.py similarity index 97% rename from src/borg/testsuite/crypto_test.py rename to src/borg/testsuite/crypto/crypto_test.py index 7c6ba0b22..edaa8b9cf 100644 --- a/src/borg/testsuite/crypto_test.py +++ b/src/borg/testsuite/crypto/crypto_test.py @@ -4,14 +4,14 @@ from unittest.mock import MagicMock import unittest -from ..crypto.low_level import AES256_CTR_HMAC_SHA256, AES256_OCB, CHACHA20_POLY1305, UNENCRYPTED, IntegrityError -from ..crypto.low_level import bytes_to_long, bytes_to_int, long_to_bytes -from ..crypto.low_level import AES, hmac_sha256 +from ...crypto.low_level import AES256_CTR_HMAC_SHA256, AES256_OCB, CHACHA20_POLY1305, UNENCRYPTED, IntegrityError +from ...crypto.low_level import bytes_to_long, bytes_to_int, long_to_bytes +from ...crypto.low_level import AES, hmac_sha256 from hashlib import sha256 -from ..crypto.key import CHPOKeyfileKey, AESOCBRepoKey, FlexiKey, KeyBase, PlaintextKey -from ..helpers import msgpack, bin_to_hex +from ...crypto.key import CHPOKeyfileKey, AESOCBRepoKey, FlexiKey, KeyBase, PlaintextKey +from ...helpers import msgpack, bin_to_hex -from . import BaseTestCase +from .. import BaseTestCase class CryptoTestCase(BaseTestCase): diff --git a/src/borg/testsuite/file_integrity_test.py b/src/borg/testsuite/crypto/file_integrity_test.py similarity index 98% rename from src/borg/testsuite/file_integrity_test.py rename to src/borg/testsuite/crypto/file_integrity_test.py index 95add54ef..052bad81c 100644 --- a/src/borg/testsuite/file_integrity_test.py +++ b/src/borg/testsuite/crypto/file_integrity_test.py @@ -1,6 +1,6 @@ import pytest -from ..crypto.file_integrity import DetachedIntegrityCheckedFile, FileIntegrityError +from ...crypto.file_integrity import DetachedIntegrityCheckedFile, FileIntegrityError class TestReadIntegrityFile: diff --git a/src/borg/testsuite/key_test.py b/src/borg/testsuite/crypto/key_test.py similarity index 93% rename from src/borg/testsuite/key_test.py rename to src/borg/testsuite/crypto/key_test.py index 14c46a0c4..ca2884e29 100644 --- a/src/borg/testsuite/key_test.py +++ b/src/borg/testsuite/crypto/key_test.py @@ -4,20 +4,20 @@ from unittest.mock import MagicMock import pytest -from ..crypto.key import PlaintextKey, AuthenticatedKey, Blake2AuthenticatedKey -from ..crypto.key import RepoKey, KeyfileKey, Blake2RepoKey, Blake2KeyfileKey -from ..crypto.key import AEADKeyBase -from ..crypto.key import AESOCBRepoKey, AESOCBKeyfileKey, CHPORepoKey, CHPOKeyfileKey -from ..crypto.key import Blake2AESOCBRepoKey, Blake2AESOCBKeyfileKey, Blake2CHPORepoKey, Blake2CHPOKeyfileKey -from ..crypto.key import ID_HMAC_SHA_256, ID_BLAKE2b_256 -from ..crypto.key import UnsupportedManifestError, UnsupportedKeyFormatError -from ..crypto.key import identify_key -from ..crypto.low_level import IntegrityError as IntegrityErrorBase -from ..helpers import IntegrityError -from ..helpers import Location -from ..helpers import msgpack -from ..constants import KEY_ALGORITHMS -from ..helpers import hex_to_bin, bin_to_hex +from ...crypto.key import PlaintextKey, AuthenticatedKey, Blake2AuthenticatedKey +from ...crypto.key import RepoKey, KeyfileKey, Blake2RepoKey, Blake2KeyfileKey +from ...crypto.key import AEADKeyBase +from ...crypto.key import AESOCBRepoKey, AESOCBKeyfileKey, CHPORepoKey, CHPOKeyfileKey +from ...crypto.key import Blake2AESOCBRepoKey, Blake2AESOCBKeyfileKey, Blake2CHPORepoKey, Blake2CHPOKeyfileKey +from ...crypto.key import ID_HMAC_SHA_256, ID_BLAKE2b_256 +from ...crypto.key import UnsupportedManifestError, UnsupportedKeyFormatError +from ...crypto.key import identify_key +from ...crypto.low_level import IntegrityError as IntegrityErrorBase +from ...helpers import IntegrityError +from ...helpers import Location +from ...helpers import msgpack +from ...constants import KEY_ALGORITHMS +from ...helpers import hex_to_bin, bin_to_hex class TestKey: diff --git a/src/borg/testsuite/efficient_collection_queue_test.py b/src/borg/testsuite/helpers/efficient_collection_queue_test.py similarity index 96% rename from src/borg/testsuite/efficient_collection_queue_test.py rename to src/borg/testsuite/helpers/efficient_collection_queue_test.py index aab2cf9b2..e80b11b90 100644 --- a/src/borg/testsuite/efficient_collection_queue_test.py +++ b/src/borg/testsuite/helpers/efficient_collection_queue_test.py @@ -1,6 +1,6 @@ import pytest -from ..helpers.datastruct import EfficientCollectionQueue +from ...helpers.datastruct import EfficientCollectionQueue class TestEfficientQueue: diff --git a/src/borg/testsuite/lrucache_test.py b/src/borg/testsuite/helpers/lrucache_test.py similarity index 97% rename from src/borg/testsuite/lrucache_test.py rename to src/borg/testsuite/helpers/lrucache_test.py index a3b13c1b7..8897702f2 100644 --- a/src/borg/testsuite/lrucache_test.py +++ b/src/borg/testsuite/helpers/lrucache_test.py @@ -2,7 +2,7 @@ from tempfile import TemporaryFile import pytest -from ..helpers.lrucache import LRUCache +from ...helpers.lrucache import LRUCache class TestLRUCache: diff --git a/src/borg/testsuite/nanorst_test.py b/src/borg/testsuite/helpers/nanorst_test.py similarity index 95% rename from src/borg/testsuite/nanorst_test.py rename to src/borg/testsuite/helpers/nanorst_test.py index dc2f4f848..dad408db0 100644 --- a/src/borg/testsuite/nanorst_test.py +++ b/src/borg/testsuite/helpers/nanorst_test.py @@ -1,6 +1,6 @@ import pytest -from ..helpers.nanorst import rst_to_text +from ...helpers.nanorst import rst_to_text def test_inline(): diff --git a/src/borg/testsuite/platform/__init__.py b/src/borg/testsuite/platform/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/borg/testsuite/platform_darwin_test.py b/src/borg/testsuite/platform/darwin_test.py similarity index 97% rename from src/borg/testsuite/platform_darwin_test.py rename to src/borg/testsuite/platform/darwin_test.py index ca816c561..900355300 100644 --- a/src/borg/testsuite/platform_darwin_test.py +++ b/src/borg/testsuite/platform/darwin_test.py @@ -1,7 +1,7 @@ import os import tempfile -from ..platform import acl_get, acl_set +from ...platform import acl_get, acl_set from .platform_test import skipif_not_darwin, skipif_fakeroot_detected, skipif_acls_not_working # set module-level skips diff --git a/src/borg/testsuite/platform_freebsd_test.py b/src/borg/testsuite/platform/freebsd_test.py similarity index 98% rename from src/borg/testsuite/platform_freebsd_test.py rename to src/borg/testsuite/platform/freebsd_test.py index b86588230..c64c544ee 100644 --- a/src/borg/testsuite/platform_freebsd_test.py +++ b/src/borg/testsuite/platform/freebsd_test.py @@ -1,7 +1,7 @@ import os import tempfile -from ..platform import acl_get, acl_set +from ...platform import acl_get, acl_set from .platform_test import skipif_not_freebsd, skipif_acls_not_working # set module-level skips diff --git a/src/borg/testsuite/platform_linux_test.py b/src/borg/testsuite/platform/linux_test.py similarity index 97% rename from src/borg/testsuite/platform_linux_test.py rename to src/borg/testsuite/platform/linux_test.py index 8700e9d2b..6e760952a 100644 --- a/src/borg/testsuite/platform_linux_test.py +++ b/src/borg/testsuite/platform/linux_test.py @@ -1,7 +1,7 @@ import os import tempfile -from ..platform import acl_get, acl_set +from ...platform import acl_get, acl_set from .platform_test import skipif_not_linux, skipif_fakeroot_detected, skipif_acls_not_working, skipif_no_ubel_user # set module-level skips @@ -116,7 +116,7 @@ def test_non_ascii_acl(): def test_utils(): - from ..platform.linux import acl_use_local_uid_gid + from ...platform.linux import acl_use_local_uid_gid assert acl_use_local_uid_gid(b"user:nonexistent1234:rw-:1234") == b"user:1234:rw-" assert acl_use_local_uid_gid(b"group:nonexistent1234:rw-:1234") == b"group:1234:rw-" diff --git a/src/borg/testsuite/platform_test.py b/src/borg/testsuite/platform/platform_test.py similarity index 91% rename from src/borg/testsuite/platform_test.py rename to src/borg/testsuite/platform/platform_test.py index 725d00511..4c763d8f9 100644 --- a/src/borg/testsuite/platform_test.py +++ b/src/borg/testsuite/platform/platform_test.py @@ -4,11 +4,11 @@ import os import pytest -from ..platformflags import is_darwin, is_freebsd, is_linux, is_win32 -from ..platform import acl_get, acl_set -from ..platform import get_process_id, process_alive -from . import unopened_tempfile -from .fslocking_test import free_pid # NOQA +from ...platformflags import is_darwin, is_freebsd, is_linux, is_win32 +from ...platform import acl_get, acl_set +from ...platform import get_process_id, process_alive +from .. import unopened_tempfile +from ..fslocking_test import free_pid # NOQA def fakeroot_detected(): @@ -77,7 +77,7 @@ skipif_acls_not_working = pytest.mark.skipif(not are_acls_working(), reason="ACL skipif_no_ubel_user = pytest.mark.skipif(not user_exists("übel"), reason="requires übel user") -def test_process_alive(free_pid): +def test_process_alive(free_pid): # NOQA id = get_process_id() assert process_alive(*id) host, pid, tid = id diff --git a/src/borg/testsuite/platform_posix_test.py b/src/borg/testsuite/platform/posix_test.py similarity index 91% rename from src/borg/testsuite/platform_posix_test.py rename to src/borg/testsuite/platform/posix_test.py index f9328b949..7e97d084f 100644 --- a/src/borg/testsuite/platform_posix_test.py +++ b/src/borg/testsuite/platform/posix_test.py @@ -1,4 +1,4 @@ -from ..platform import swidth +from ...platform import swidth from .platform_test import skipif_not_posix diff --git a/src/borg/testsuite/remote_test.py b/src/borg/testsuite/remote_test.py index 26b57e197..aeb0b33c7 100644 --- a/src/borg/testsuite/remote_test.py +++ b/src/borg/testsuite/remote_test.py @@ -14,7 +14,7 @@ from ..helpers import IntegrityError from ..repoobj import RepoObj from .hashindex_test import H from .repository_test import fchunk, pdchunk -from .key_test import TestKey +from .crypto.key_test import TestKey class TestSleepingBandwidthLimiter: