Repository: borgbackup/borg (language: python)

Issue:
borg2: move test suite, rename test files?
Getting #6386 to work was a bit more complicated than expected and especially the need for a `pytest.ini` (or same options given on the cmdline) was a bit ugly.

So, guess we could rename `borg/testsuite` to `tests` (or so), so that pytest finds it by default.

Also check if the test files need renaming (like to `test_something.py`?), so they are also found by default.

how to run self tests from pypi distfile
I've updated the pkgsrc package, which is using the pypi distfile, to 1.2.0 and wanted to run the self tests to verify that the package works as expected.

I tried the following:
```
setup.py test
```
but this reported
```
...
Ran 0 tests in 0.000s
```

Then I tried using pytest, but got another error:
```
platform netbsd9 -- Python 3.10.2, pytest-7.0.1, pluggy-0.13.1                                                                                           
Tests enabled: BSD flags, root, symlinks, hardlinks, atime/mtime, modes                                                                                  
Tests disabled: fuse2, fuse3                                                
rootdir: /scratch/sysutils/py-borgbackup/work/borgbackup-1.2.0, configfile: setup.cfg
collected 0 items / 29 errors                                                                                                                                                                                                                                                                                     
======================================================================== ERRORS =========================================================================
____________________________________________________ ERROR collecting src/borg/testsuite/archive.py _____________________________________________________
import file mismatch:                                                                                                                                    
imported module 'borg.testsuite.archive' has this __file__ attribute:                                                                                    
  /usr/pkg/lib/python3.10/site-packages/borg/testsuite/archive.py                                                                                        
which is not the same as the test file we want to collect:                  
  /scratch/sysutils/py-borgbackup/work/borgbackup-1.2.0/src/borg/testsuite/archive.py                   
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
...
_____________________________________________________ ERROR collecting src/borg/testsuite/xattr.py ______________________________________________________import file mismatch:                                                                                                                                    imported module 'borg.testsuite.xattr' has this __file__ attribute:                                                                                        /usr/pkg/lib/python3.10/site-packages/borg/testsuite/xattr.py                                                                                          which is not the same as the test file we want to collect:                                                                                                 /scratch/sysutils/py-borgbackup/work/borgbackup-1.2.0/src/borg/testsuite/xattr.py                                                                      HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules                                                            ================================================================ short test summary info ================================================================ERROR src/borg/testsuite/archive.py                                                                                                                      ERROR src/borg/testsuite/archiver.py                                                                                                                     ERROR src/borg/testsuite/benchmark.py                                                                                                                    ERROR src/borg/testsuite/cache.py                                                                                                                        ERROR src/borg/testsuite/checksums.py                                                                                                                    ERROR src/borg/testsuite/chunker.py                                                                                                                      ERROR src/borg/testsuite/chunker_pytest.py                                                                                                               ERROR src/borg/testsuite/chunker_slow.py                                                                                                                 ERROR src/borg/testsuite/compress.py                                                                                                                     
ERROR src/borg/testsuite/crypto.py                                                                                                                       
ERROR src/borg/testsuite/efficient_collection_queue.py                                                                                                   
ERROR src/borg/testsuite/file_integrity.py                                                                                                               
ERROR src/borg/testsuite/hashindex.py                                                                                                                    
ERROR src/borg/testsuite/helpers.py                                         
ERROR src/borg/testsuite/item.py                                                                                                                         
ERROR src/borg/testsuite/key.py                                                                                                                          ERROR src/borg/testsuite/locking.py                                                                                                                      
ERROR src/borg/testsuite/logger.py                                                                                                                       
ERROR src/borg/testsuite/lrucache.py                                                                                                                     
ERROR src/borg/testsuite/nanorst.py                                                                                                                      
ERROR src/borg/testsuite/nonces.py                                                                                                                       
ERROR src/borg/testsuite/patterns.py                                                                                                                     
ERROR src/borg/testsuite/platform.py                                        
ERROR src/borg/testsuite/remote.py                                                                                                                       
ERROR src/borg/testsuite/repository.py                                                                                                                   
ERROR src/borg/testsuite/shellpattern.py                                                                                                                 
ERROR src/borg/testsuite/upgrader.py                                                                                                                     
ERROR src/borg/testsuite/version.py                                                                                                                      
ERROR src/borg/testsuite/xattr.py                                           
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 29 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================== 29 errors in 3.24s ===================================================================
```

What is the proper way to run the tests from the pypi distfile?

Environment:
NetBSD 9.99.93/amd64, python 3.10.2, zstd 1.5.2, lz4 1.9.3, libb2 0.98.1, cython 0.29.27, msgpack 1.0.3, pytest 7.0.1.


Discussion / hints:
Looks like primarily the test files need renaming:

https://docs.pytest.org/en/stable/explanation/goodpractices.html#conventions-for-python-test-discovery

So, it is either `test_*.py` or `*_test.py` to be found "by default".

The self-tests (a few quick tests) will run automatically each time you use borg.

We did not make any special provisions so that you can run the tests from the pypi package yet.

The tests need some addtl. packages, see `requirements.d/development.txt` and regularly run on github actions for each commit / pull request. Developers also can run them locally after doing a git checkout of the repo and setting up the environment as described in the install docs ("from source").

Also, when doing a release, I do vagrant-based platform testing, including on netbsd.

If you want to help with the netbsd situation, see #5922.

Trying to make this work for borg 1.4:
```
# optional: create and use a virtual env:
python3 -m venv env
. env/bin/activate

# install packages
pip install borgbackup-from-pypi.tgz
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 = -v -rs --benchmark-skip
EOF

pytest --pyargs borg.testsuite

# method B: give the options via the cmdline (each time you invoke the tests):

pytest -v -rs --benchmark-skip -o 'python_files=testsuite/*.py' -o 'markers=allow_cache_wipe' --pyargs borg.testsuite

```


Fix patch:
diff --git a/docs/development.rst b/docs/development.rst
index 8c389262bf..fc56f4bd71 100644
--- a/docs/development.rst
+++ b/docs/development.rst
@@ -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
diff --git a/pyproject.toml b/pyproject.toml
index fcadcc01f5..62c8e42f2d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -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"


Test patch:
diff --git a/src/borg/selftest.py b/src/borg/selftest.py
index e53ae06837..cb1ef7a8c1 100644
--- a/src/borg/selftest.py
+++ b/src/borg/selftest.py
@@ -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,
diff --git a/src/borg/testsuite/archive.py b/src/borg/testsuite/archive_test.py
similarity index 100%
rename from src/borg/testsuite/archive.py
rename to src/borg/testsuite/archive_test.py
diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py
index 89500283be..44cd80866e 100644
--- a/src/borg/testsuite/archiver/__init__.py
+++ b/src/borg/testsuite/archiver/__init__.py
@@ -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"
diff --git a/src/borg/testsuite/archiver/analyze_cmd.py b/src/borg/testsuite/archiver/analyze_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/analyze_cmd.py
rename to src/borg/testsuite/archiver/analyze_cmd_test.py
diff --git a/src/borg/testsuite/archiver/argparsing.py b/src/borg/testsuite/archiver/argparsing_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/argparsing.py
rename to src/borg/testsuite/archiver/argparsing_test.py
diff --git a/src/borg/testsuite/archiver/benchmark_cmd.py b/src/borg/testsuite/archiver/benchmark_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/benchmark_cmd.py
rename to src/borg/testsuite/archiver/benchmark_cmd_test.py
diff --git a/src/borg/testsuite/archiver/check_cmd.py b/src/borg/testsuite/archiver/check_cmd_test.py
similarity index 99%
rename from src/borg/testsuite/archiver/check_cmd.py
rename to src/borg/testsuite/archiver/check_cmd_test.py
index 78742a01d1..0eb19e7f10 100644
--- a/src/borg/testsuite/archiver/check_cmd.py
+++ b/src/borg/testsuite/archiver/check_cmd_test.py
@@ -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
diff --git a/src/borg/testsuite/archiver/checks.py b/src/borg/testsuite/archiver/checks_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/checks.py
rename to src/borg/testsuite/archiver/checks_test.py
diff --git a/src/borg/testsuite/archiver/compact_cmd.py b/src/borg/testsuite/archiver/compact_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/compact_cmd.py
rename to src/borg/testsuite/archiver/compact_cmd_test.py
diff --git a/src/borg/testsuite/archiver/corruption.py b/src/borg/testsuite/archiver/corruption_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/corruption.py
rename to src/borg/testsuite/archiver/corruption_test.py
diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/create_cmd.py
rename to src/borg/testsuite/archiver/create_cmd_test.py
diff --git a/src/borg/testsuite/archiver/debug_cmds.py b/src/borg/testsuite/archiver/debug_cmds_test.py
similarity index 99%
rename from src/borg/testsuite/archiver/debug_cmds.py
rename to src/borg/testsuite/archiver/debug_cmds_test.py
index 8b73e9d252..dcb9acfaaa 100644
--- a/src/borg/testsuite/archiver/debug_cmds.py
+++ b/src/borg/testsuite/archiver/debug_cmds_test.py
@@ -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
diff --git a/src/borg/testsuite/archiver/delete_cmd.py b/src/borg/testsuite/archiver/delete_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/delete_cmd.py
rename to src/borg/testsuite/archiver/delete_cmd_test.py
diff --git a/src/borg/testsuite/archiver/diff_cmd.py b/src/borg/testsuite/archiver/diff_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/diff_cmd.py
rename to src/borg/testsuite/archiver/diff_cmd_test.py
diff --git a/src/borg/testsuite/archiver/disk_full.py b/src/borg/testsuite/archiver/disk_full_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/disk_full.py
rename to src/borg/testsuite/archiver/disk_full_test.py
diff --git a/src/borg/testsuite/archiver/extract_cmd.py b/src/borg/testsuite/archiver/extract_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/extract_cmd.py
rename to src/borg/testsuite/archiver/extract_cmd_test.py
diff --git a/src/borg/testsuite/archiver/help_cmd.py b/src/borg/testsuite/archiver/help_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/help_cmd.py
rename to src/borg/testsuite/archiver/help_cmd_test.py
diff --git a/src/borg/testsuite/archiver/info_cmd.py b/src/borg/testsuite/archiver/info_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/info_cmd.py
rename to src/borg/testsuite/archiver/info_cmd_test.py
diff --git a/src/borg/testsuite/archiver/key_cmds.py b/src/borg/testsuite/archiver/key_cmds_test.py
similarity index 99%
rename from src/borg/testsuite/archiver/key_cmds.py
rename to src/borg/testsuite/archiver/key_cmds_test.py
index b799fb1ccd..79d933f228 100644
--- a/src/borg/testsuite/archiver/key_cmds.py
+++ b/src/borg/testsuite/archiver/key_cmds_test.py
@@ -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
@@ -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
diff --git a/src/borg/testsuite/archiver/list_cmd.py b/src/borg/testsuite/archiver/list_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/list_cmd.py
rename to src/borg/testsuite/archiver/list_cmd_test.py
diff --git a/src/borg/testsuite/archiver/lock_cmds.py b/src/borg/testsuite/archiver/lock_cmds_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/lock_cmds.py
rename to src/borg/testsuite/archiver/lock_cmds_test.py
diff --git a/src/borg/testsuite/archiver/mount_cmds.py b/src/borg/testsuite/archiver/mount_cmds_test.py
similarity index 99%
rename from src/borg/testsuite/archiver/mount_cmds.py
rename to src/borg/testsuite/archiver/mount_cmds_test.py
index f946825b12..7c60e394c8 100644
--- a/src/borg/testsuite/archiver/mount_cmds.py
+++ b/src/borg/testsuite/archiver/mount_cmds_test.py
@@ -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
 
diff --git a/src/borg/testsuite/archiver/patterns.py b/src/borg/testsuite/archiver/patterns_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/patterns.py
rename to src/borg/testsuite/archiver/patterns_test.py
diff --git a/src/borg/testsuite/archiver/prune_cmd.py b/src/borg/testsuite/archiver/prune_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/prune_cmd.py
rename to src/borg/testsuite/archiver/prune_cmd_test.py
diff --git a/src/borg/testsuite/archiver/recreate_cmd.py b/src/borg/testsuite/archiver/recreate_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/recreate_cmd.py
rename to src/borg/testsuite/archiver/recreate_cmd_test.py
diff --git a/src/borg/testsuite/archiver/rename_cmd.py b/src/borg/testsuite/archiver/rename_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/rename_cmd.py
rename to src/borg/testsuite/archiver/rename_cmd_test.py
diff --git a/src/borg/testsuite/archiver/repo_compress_cmd.py b/src/borg/testsuite/archiver/repo_compress_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/repo_compress_cmd.py
rename to src/borg/testsuite/archiver/repo_compress_cmd_test.py
diff --git a/src/borg/testsuite/archiver/repo_create_cmd.py b/src/borg/testsuite/archiver/repo_create_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/repo_create_cmd.py
rename to src/borg/testsuite/archiver/repo_create_cmd_test.py
diff --git a/src/borg/testsuite/archiver/repo_delete_cmd.py b/src/borg/testsuite/archiver/repo_delete_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/repo_delete_cmd.py
rename to src/borg/testsuite/archiver/repo_delete_cmd_test.py
diff --git a/src/borg/testsuite/archiver/repo_info_cmd.py b/src/borg/testsuite/archiver/repo_info_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/repo_info_cmd.py
rename to src/borg/testsuite/archiver/repo_info_cmd_test.py
diff --git a/src/borg/testsuite/archiver/repo_list_cmd.py b/src/borg/testsuite/archiver/repo_list_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/repo_list_cmd.py
rename to src/borg/testsuite/archiver/repo_list_cmd_test.py
diff --git a/src/borg/testsuite/archiver/return_codes.py b/src/borg/testsuite/archiver/return_codes_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/return_codes.py
rename to src/borg/testsuite/archiver/return_codes_test.py
diff --git a/src/borg/testsuite/archiver/serve_cmd.py b/src/borg/testsuite/archiver/serve_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/serve_cmd.py
rename to src/borg/testsuite/archiver/serve_cmd_test.py
diff --git a/src/borg/testsuite/archiver/tag_cmd.py b/src/borg/testsuite/archiver/tag_cmd_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/tag_cmd.py
rename to src/borg/testsuite/archiver/tag_cmd_test.py
diff --git a/src/borg/testsuite/archiver/tar_cmds.py b/src/borg/testsuite/archiver/tar_cmds_test.py
similarity index 100%
rename from src/borg/testsuite/archiver/tar_cmds.py
rename to src/borg/testsuite/archiver/tar_cmds_test.py
diff --git a/src/borg/testsuite/archiver/transfer_cmd.py b/src/borg/testsuite/archiver/transfer_cmd_test.py
similarity index 99%
rename from src/borg/testsuite/archiver/transfer_cmd.py
rename to src/borg/testsuite/archiver/transfer_cmd_test.py
index 3ff2616f71..3084a425c8 100644
--- a/src/borg/testsuite/archiver/transfer_cmd.py
+++ b/src/borg/testsuite/archiver/transfer_cmd_test.py
@@ -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
diff --git a/src/borg/testsuite/benchmark.py b/src/borg/testsuite/benchmark_test.py
similarity index 99%
rename from src/borg/testsuite/benchmark.py
rename to src/borg/testsuite/benchmark_test.py
index 10819c1002..2fb137dc7f 100644
--- a/src/borg/testsuite/benchmark.py
+++ b/src/borg/testsuite/benchmark_test.py
@@ -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
 
 
diff --git a/src/borg/testsuite/cache.py b/src/borg/testsuite/cache_test.py
similarity index 96%
rename from src/borg/testsuite/cache.py
rename to src/borg/testsuite/cache_test.py
index ac46a6fad6..e65735459d 100644
--- a/src/borg/testsuite/cache.py
+++ b/src/borg/testsuite/cache_test.py
@@ -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
diff --git a/src/borg/testsuite/checksums.py b/src/borg/testsuite/checksums_test.py
similarity index 100%
rename from src/borg/testsuite/checksums.py
rename to src/borg/testsuite/checksums_test.py
diff --git a/src/borg/testsuite/chunker_pytest.py b/src/borg/testsuite/chunker_pytest_test.py
similarity index 99%
rename from src/borg/testsuite/chunker_pytest.py
rename to src/borg/testsuite/chunker_pytest_test.py
index dec03f8768..14692c18a8 100644
--- a/src/borg/testsuite/chunker_pytest.py
+++ b/src/borg/testsuite/chunker_pytest_test.py
@@ -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
 
diff --git a/src/borg/testsuite/chunker_slow.py b/src/borg/testsuite/chunker_slow_test.py
similarity index 97%
rename from src/borg/testsuite/chunker_slow.py
rename to src/borg/testsuite/chunker_slow_test.py
index 1737ef4053..a2cec4f61e 100644
--- a/src/borg/testsuite/chunker_slow.py
+++ b/src/borg/testsuite/chunker_slow_test.py
@@ -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
diff --git a/src/borg/testsuite/chunker.py b/src/borg/testsuite/chunker_test.py
similarity index 100%
rename from src/borg/testsuite/chunker.py
rename to src/borg/testsuite/chunker_test.py
diff --git a/src/borg/testsuite/compress.py b/src/borg/testsuite/compress_test.py
similarity index 100%
rename from src/borg/testsuite/compress.py
rename to src/borg/testsuite/compress_test.py
diff --git a/src/borg/testsuite/conftest.py b/src/borg/testsuite/conftest.py
index fc3862688a..5e6b9c92db 100644
--- a/src/borg/testsuite/conftest.py
+++ b/src/borg/testsuite/conftest.py
@@ -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)
diff --git a/src/borg/testsuite/crypto.py b/src/borg/testsuite/crypto_test.py
similarity index 100%
rename from src/borg/testsuite/crypto.py
rename to src/borg/testsuite/crypto_test.py
diff --git a/src/borg/testsuite/efficient_collection_queue.py b/src/borg/testsuite/efficient_collection_queue_test.py
similarity index 100%
rename from src/borg/testsuite/efficient_collection_queue.py
rename to src/borg/testsuite/efficient_collection_queue_test.py
diff --git a/src/borg/testsuite/file_integrity.py b/src/borg/testsuite/file_integrity_test.py
similarity index 100%
rename from src/borg/testsuite/file_integrity.py
rename to src/borg/testsuite/file_integrity_test.py
diff --git a/src/borg/testsuite/fslocking.py b/src/borg/testsuite/fslocking_test.py
similarity index 100%
rename from src/borg/testsuite/fslocking.py
rename to src/borg/testsuite/fslocking_test.py
diff --git a/src/borg/testsuite/hashindex_pytest.py b/src/borg/testsuite/hashindex_pytest_test.py
similarity index 100%
rename from src/borg/testsuite/hashindex_pytest.py
rename to src/borg/testsuite/hashindex_pytest_test.py
diff --git a/src/borg/testsuite/hashindex.py b/src/borg/testsuite/hashindex_test.py
similarity index 100%
rename from src/borg/testsuite/hashindex.py
rename to src/borg/testsuite/hashindex_test.py
diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers_test.py
similarity index 100%
rename from src/borg/testsuite/helpers.py
rename to src/borg/testsuite/helpers_test.py
diff --git a/src/borg/testsuite/item.py b/src/borg/testsuite/item_test.py
similarity index 100%
rename from src/borg/testsuite/item.py
rename to src/borg/testsuite/item_test.py
diff --git a/src/borg/testsuite/key.py b/src/borg/testsuite/key_test.py
similarity index 100%
rename from src/borg/testsuite/key.py
rename to src/borg/testsuite/key_test.py
diff --git a/src/borg/testsuite/legacyrepository.py b/src/borg/testsuite/legacyrepository_test.py
similarity index 99%
rename from src/borg/testsuite/legacyrepository.py
rename to src/borg/testsuite/legacyrepository_test.py
index d4e33097bf..df21d7df86 100644
--- a/src/borg/testsuite/legacyrepository.py
+++ b/src/borg/testsuite/legacyrepository_test.py
@@ -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()
diff --git a/src/borg/testsuite/logger.py b/src/borg/testsuite/logger_test.py
similarity index 69%
rename from src/borg/testsuite/logger.py
rename to src/borg/testsuite/logger_test.py
index d24ec0fd11..1e45f88785 100644
--- a/src/borg/testsuite/logger.py
+++ b/src/borg/testsuite/logger_test.py
@@ -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():
diff --git a/src/borg/testsuite/lrucache.py b/src/borg/testsuite/lrucache_test.py
similarity index 100%
rename from src/borg/testsuite/lrucache.py
rename to src/borg/testsuite/lrucache_test.py
diff --git a/src/borg/testsuite/nanorst.py b/src/borg/testsuite/nanorst_test.py
similarity index 100%
rename from src/borg/testsuite/nanorst.py
rename to src/borg/testsuite/nanorst_test.py
diff --git a/src/borg/testsuite/patterns.py b/src/borg/testsuite/patterns_test.py
similarity index 100%
rename from src/borg/testsuite/patterns.py
rename to src/borg/testsuite/patterns_test.py
diff --git a/src/borg/testsuite/platform_darwin.py b/src/borg/testsuite/platform_darwin_test.py
similarity index 94%
rename from src/borg/testsuite/platform_darwin.py
rename to src/borg/testsuite/platform_darwin_test.py
index 8921beedcf..ca816c561b 100644
--- a/src/borg/testsuite/platform_darwin.py
+++ b/src/borg/testsuite/platform_darwin_test.py
@@ -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]
diff --git a/src/borg/testsuite/platform_freebsd.py b/src/borg/testsuite/platform_freebsd_test.py
similarity index 97%
rename from src/borg/testsuite/platform_freebsd.py
rename to src/borg/testsuite/platform_freebsd_test.py
index c47da68b69..b865882308 100644
--- a/src/borg/testsuite/platform_freebsd.py
+++ b/src/borg/testsuite/platform_freebsd_test.py
@@ -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]
diff --git a/src/borg/testsuite/platform_linux.py b/src/borg/testsuite/platform_linux_test.py
similarity index 97%
rename from src/borg/testsuite/platform_linux.py
rename to src/borg/testsuite/platform_linux_test.py
index e41f391873..8700e9d2b0 100644
--- a/src/borg/testsuite/platform_linux.py
+++ b/src/borg/testsuite/platform_linux_test.py
@@ -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]
diff --git a/src/borg/testsuite/platform_posix.py b/src/borg/testsuite/platform_posix_test.py
similarity index 87%
rename from src/borg/testsuite/platform_posix.py
rename to src/borg/testsuite/platform_posix_test.py
index 98faed9fec..f9328b9499 100644
--- a/src/borg/testsuite/platform_posix.py
+++ b/src/borg/testsuite/platform_posix_test.py
@@ -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
diff --git a/src/borg/testsuite/platform.py b/src/borg/testsuite/platform_test.py
similarity index 98%
rename from src/borg/testsuite/platform.py
rename to src/borg/testsuite/platform_test.py
index 527bb11787..725d00511c 100644
--- a/src/borg/testsuite/platform.py
+++ b/src/borg/testsuite/platform_test.py
@@ -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():
diff --git a/src/borg/testsuite/remote.py b/src/borg/testsuite/remote_test.py
similarity index 98%
rename from src/borg/testsuite/remote.py
rename to src/borg/testsuite/remote_test.py
index a2d84bcee8..1e64525e2a 100644
--- a/src/borg/testsuite/remote.py
+++ b/src/borg/testsuite/remote_test.py
@@ -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:
diff --git a/src/borg/testsuite/repoobj.py b/src/borg/testsuite/repoobj_test.py
similarity index 100%
rename from src/borg/testsuite/repoobj.py
rename to src/borg/testsuite/repoobj_test.py
diff --git a/src/borg/testsuite/repository.py b/src/borg/testsuite/repository_test.py
similarity index 99%
rename from src/borg/testsuite/repository.py
rename to src/borg/testsuite/repository_test.py
index 05cb74ea40..60e40dbf44 100644
--- a/src/borg/testsuite/repository.py
+++ b/src/borg/testsuite/repository_test.py
@@ -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()
diff --git a/src/borg/testsuite/shellpattern.py b/src/borg/testsuite/shellpattern_test.py
similarity index 100%
rename from src/borg/testsuite/shellpattern.py
rename to src/borg/testsuite/shellpattern_test.py
diff --git a/src/borg/testsuite/storelocking.py b/src/borg/testsuite/storelocking_test.py
similarity index 100%
rename from src/borg/testsuite/storelocking.py
rename to src/borg/testsuite/storelocking_test.py
diff --git a/src/borg/testsuite/version.py b/src/borg/testsuite/version_test.py
similarity index 100%
rename from src/borg/testsuite/version.py
rename to src/borg/testsuite/version_test.py
diff --git a/src/borg/testsuite/xattr.py b/src/borg/testsuite/xattr_test.py
similarity index 100%
rename from src/borg/testsuite/xattr.py
rename to src/borg/testsuite/xattr_test.py