borg/.pre-commit-config.yaml
Thomas Waldmann 61f490a66b
testsuite: move conftest.py into the borg.testsuite package
The autouse test-isolation fixtures (clean_env, reset_progress_logger,
default_patches) lived only in the repo-root conftest.py. That file is not
installed with the package, and pytest does not apply a rootdir conftest's
fixtures to tests collected from a different directory tree. On CI the tests
run against the sdist-installed package via `pytest --pyargs borg.testsuite`
(tox), i.e. from site-packages/borg/testsuite/ - so the fixtures never ran
there, and tests leaked state into each other:

- BORG_NEW_PASSPHRASE leaked from test_change_passphrase, making later
  repokey `init` encrypt with the wrong passphrase -> ~330 spurious
  PassphraseWrong failures in archiver create tests.
- XDG_CONFIG_HOME was not isolated, so nonce/key tests read+wrote the real
  security dir and poisoned each other (nonce/IV assertions).
- the borg.output.progress logger handler leaked (progress test failures).

These only showed up on py>=3.10 because pytest is unpinned: py3.9 resolves
an older pytest that still applied the rootdir fixtures to --pyargs tests.

Move conftest.py into src/borg/testsuite/ (matching 1.4-maint/master) so it
is installed alongside the tests and its fixtures always apply. Adjust the
flake8 / pre-commit targets accordingly (it is now covered by `flake8 src`).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bFWgq2KV6oYxmfH6Zqvp3
2026-07-20 14:58:59 +02:00

6 lines
125 B
YAML

repos:
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
files: '(src|scripts)'