Skip to content

Commit

Permalink
Merge pull request borgbackup#8452 from ThomasWaldmann/rename-test-files
Browse files Browse the repository at this point in the history
Rename test files
  • Loading branch information
ThomasWaldmann authored Oct 4, 2024
2 parents b2bdf5e + 090ee52 commit ea619e7
Show file tree
Hide file tree
Showing 72 changed files with 41 additions and 54 deletions.
16 changes: 2 additions & 14 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,8 @@ github releases page)::
pip install borgbackup
pip install pytest pytest-benchmark

# method A: use a pytest.ini

cat >pytest.ini <<<EOF
[pytest]
python_files = testsuite/*.py
markers = allow_cache_wipe
addopts = -rs --benchmark-skip
EOF

pytest --pyargs borg.testsuite

# method B: give the options via the cmdline (each time you invoke the tests):

pytest -rs --benchmark-skip -o 'python_files=testsuite/*.py' -o 'markers=allow_cache_wipe' --pyargs borg.testsuite
# run the tests
pytest -v -rs --benchmark-skip --pyargs borg.testsuite


Adding a compression algorithm
Expand Down
13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,13 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
"src/borg/cache.py" = ["E501"]
"src/borg/helpers/__init__.py" = ["F401"]
"src/borg/platform/__init__.py" = ["F401"]
"src/borg/testsuite/archiver/disk_full.py" = ["F811"]
"src/borg/testsuite/archiver/return_codes.py" = ["F811"]
"src/borg/testsuite/benchmark.py" = ["F811"]
"src/borg/testsuite/platform.py" = ["F811"]
"src/borg/testsuite/archiver/disk_full_test.py" = ["F811"]
"src/borg/testsuite/archiver/return_codes_test.py" = ["F811"]
"src/borg/testsuite/benchmark_test.py" = ["F811"]
"src/borg/testsuite/platform_test.py" = ["F811"]

[tool.pytest.ini_options]
python_files = "testsuite/*.py"
markers = [
"allow_cache_wipe",
]
markers = []

[tool.mypy]
python_version = "3.9"
Expand Down
6 changes: 3 additions & 3 deletions src/borg/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import time
from unittest import TestResult, TestSuite, defaultTestLoader

from .testsuite.hashindex import HashIndexDataTestCase, HashIndexRefcountingTestCase, HashIndexTestCase
from .testsuite.crypto import CryptoTestCase
from .testsuite.chunker import ChunkerTestCase
from .testsuite.hashindex_test import HashIndexDataTestCase, HashIndexRefcountingTestCase, HashIndexTestCase
from .testsuite.crypto_test import CryptoTestCase
from .testsuite.chunker_test import ChunkerTestCase

SELFTEST_CASES = [
HashIndexDataTestCase,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/borg/testsuite/archiver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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 import is_win32
from ..platform_test import is_win32
from ...xattr import get_all

RK_ENCRYPTION = "--encryption=repokey-aes-ocb"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ...manifest import Manifest
from ...remote import RemoteRepository
from ...repository import Repository
from ..repository import fchunk
from ..repository_test import fchunk
from . import cmd, src_file, create_src_archive, open_archive, generate_archiver_tests, RK_ENCRYPTION

pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ...constants import * # NOQA
from .. import changedir
from ..compress import Compressor
from ..compress_test import Compressor
from . import cmd, create_test_files, create_regular_file, generate_archiver_tests, RK_ENCRYPTION

pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ...helpers import bin_to_hex, hex_to_bin
from ...helpers import msgpack
from ...repository import Repository
from .. import key
from ..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
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_key_export_repokey(archivers, request):
repo_key = AESOCBRepoKey(repository)
repo_key.load(None, Passphrase.env_passphrase())

backup_key = AESOCBKeyfileKey(key.TestKey.MockRepository())
backup_key = AESOCBKeyfileKey(TestKey.MockRepository())
backup_key.load(export_file, Passphrase.env_passphrase())

assert repo_key.crypt_key == backup_key.crypt_key
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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 import fakeroot_detected
from ..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

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from ...constants import * # NOQA
from ...helpers.time import parse_timestamp
from ..platform import is_win32
from ..platform_test import is_win32
from . import cmd, create_test_files, RK_ENCRYPTION, open_archive, generate_archiver_tests

pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest

from .archiver import changedir, cmd_fixture # NOQA
from .item import Item
from .item_test import Item
from ..constants import zeros


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from .hashindex import H
from .key import TestKey
from .hashindex_test import H
from .key_test import TestKey
from ..archive import Statistics
from ..cache import AdHocWithFilesCache
from ..crypto.key import AESOCBRepoKey
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from .chunker import cf
from .chunker_test import cf
from ..chunker import Chunker, ChunkerFixed, sparsemap, has_seek_hole, ChunkerFailing
from ..constants import * # NOQA

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from io import BytesIO

from .chunker import cf
from .chunker_test import cf
from ..chunker import Chunker
from ..crypto.low_level import blake2b_256
from ..constants import * # NOQA
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/borg/testsuite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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.platform import fakeroot_detected # noqa: E402
from borg.testsuite.platform_test import fakeroot_detected # noqa: E402


@pytest.fixture(autouse=True)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ..legacyrepository import LegacyRepository, LoggedIO
from ..legacyrepository import MAGIC, MAX_DATA_SIZE, TAG_DELETE, TAG_PUT2, TAG_PUT, TAG_COMMIT
from ..repoobj import RepoObj
from .hashindex import H
from .hashindex_test import H


@pytest.fixture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ def io_logger():

def test_setup_logging(io_logger):
logger.info("hello world")
assert io_logger.getvalue() == "borg.testsuite.logger: hello world\n"
assert io_logger.getvalue() == "borg.testsuite.logger_test: hello world\n"


def test_multiple_loggers(io_logger):
logger = logging.getLogger(__name__)
logger.info("hello world 1")
assert io_logger.getvalue() == "borg.testsuite.logger: hello world 1\n"
logger = logging.getLogger("borg.testsuite.logger")
assert io_logger.getvalue() == "borg.testsuite.logger_test: hello world 1\n"
logger = logging.getLogger("borg.testsuite.logger_test")
logger.info("hello world 2")
assert io_logger.getvalue() == "borg.testsuite.logger: hello world 1\nborg.testsuite.logger: hello world 2\n"
assert (
io_logger.getvalue() == "borg.testsuite.logger_test: hello world 1\nborg.testsuite.logger_test: hello world 2\n"
)
io_logger.truncate(0)
io_logger.seek(0)
logger = logging.getLogger("borg.testsuite.logger")
logger = logging.getLogger("borg.testsuite.logger_test")
logger.info("hello world 2")
assert io_logger.getvalue() == "borg.testsuite.logger: hello world 2\n"
assert io_logger.getvalue() == "borg.testsuite.logger_test: hello world 2\n"


def test_parent_module():
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tempfile

from ..platform import acl_get, acl_set
from .platform import skipif_not_darwin, skipif_fakeroot_detected, skipif_acls_not_working
from .platform_test import skipif_not_darwin, skipif_fakeroot_detected, skipif_acls_not_working

# set module-level skips
pytestmark = [skipif_not_darwin, skipif_fakeroot_detected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tempfile

from ..platform import acl_get, acl_set
from .platform import skipif_not_freebsd, skipif_acls_not_working
from .platform_test import skipif_not_freebsd, skipif_acls_not_working

# set module-level skips
pytestmark = [skipif_not_freebsd]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tempfile

from ..platform import acl_get, acl_set
from .platform import skipif_not_linux, skipif_fakeroot_detected, skipif_acls_not_working, skipif_no_ubel_user
from .platform_test import skipif_not_linux, skipif_fakeroot_detected, skipif_acls_not_working, skipif_no_ubel_user

# set module-level skips
pytestmark = [skipif_not_linux, skipif_fakeroot_detected]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..platform import swidth
from .platform import skipif_not_posix
from .platform_test import skipif_not_posix


# set module-level skips
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..platform import acl_get, acl_set
from ..platform import get_process_id, process_alive
from . import unopened_tempfile
from .fslocking import free_pid # NOQA
from .fslocking_test import free_pid # NOQA


def fakeroot_detected():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from ..crypto.key import PlaintextKey
from ..helpers import IntegrityError
from ..repoobj import RepoObj
from .hashindex import H
from .repository import fchunk, pdchunk
from .key import TestKey
from .hashindex_test import H
from .repository_test import fchunk, pdchunk
from .key_test import TestKey


class TestSleepingBandwidthLimiter:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ..remote import RemoteRepository, InvalidRPCMethod, PathNotAllowed
from ..repository import Repository, MAX_DATA_SIZE
from ..repoobj import RepoObj
from .hashindex import H
from .hashindex_test import H


@pytest.fixture()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ea619e7

Please sign in to comment.