From e1510f0c73719e8ef1cded4f21bc7954f3857a6f Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 14 Jun 2025 20:05:27 +0200 Subject: [PATCH 1/2] coverage: move settings from .coveragerc to pyproject.toml --- .coveragerc | 24 ------------------------ pyproject.toml | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 25 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 8d9cdfe9c..000000000 --- a/.coveragerc +++ /dev/null @@ -1,24 +0,0 @@ -[run] -branch = True -disable_warnings = module-not-measured, no-ctracer -source = src/borg -omit = - */borg/__init__.py - */borg/__main__.py - */borg/_version.py - */borg/fuse.py - */borg/support/* - */borg/testsuite/* - */borg/hash_sizes.py - -[report] -exclude_lines = - pragma: no cover - pragma: freebsd only - pragma: unknown platform only - def __repr__ - raise AssertionError - raise NotImplementedError - if 0: - if __name__ == .__main__.: -ignore_errors = True diff --git a/pyproject.toml b/pyproject.toml index 43a61a0b6..136ebfe6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -165,7 +165,7 @@ env_list = ["py{310,311,312,313,314}-{none,fuse2,fuse3}", "docs", "ruff", "mypy" [tool.tox.env_run_base] package = "editable-legacy" # without this it does not find setup_docs when running under fakeroot deps = ["-rrequirements.d/development.txt"] -commands = [["pytest", "-v", "-n", "{env:XDISTN:1}", "-rs", "--cov=borg", "--cov-config=.coveragerc", "--benchmark-skip", "--pyargs", "{posargs:borg.testsuite}"]] +commands = [["pytest", "-v", "-n", "{env:XDISTN:1}", "-rs", "--cov=borg", "--cov-config=pyproject.toml", "--benchmark-skip", "--pyargs", "{posargs:borg.testsuite}"]] pass_env = ["*"] # fakeroot -u needs some env vars [tool.tox.env_pkg_base] @@ -208,3 +208,30 @@ skips = [ skip_install = true deps = ["bandit[toml]"] commands = [["bandit", "-r", "src/borg", "-c", "pyproject.toml"]] + +[tool.coverage.run] +branch = true +disable_warnings = ["module-not-measured", "no-ctracer"] +source = "src/borg" +omit = [ + "*/borg/__init__.py", + "*/borg/__main__.py", + "*/borg/_version.py", + "*/borg/fuse.py", + "*/borg/support/*", + "*/borg/testsuite/*", + "*/borg/hash_sizes.py", +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "pragma: freebsd only", + "pragma: unknown platform only", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", + "if 0:", + "if __name__ == .__main__.:", +] +ignore_errors = true From 91c8054215593763cdaf27473f5a92a91d685b32 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 14 Jun 2025 20:07:57 +0200 Subject: [PATCH 2/2] require coverage[toml] to support pyproject.toml on Python < 3.11 --- pyproject.toml | 2 +- requirements.d/development.lock.txt | 1 + requirements.d/development.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 136ebfe6d..4503ec1cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -212,7 +212,7 @@ commands = [["bandit", "-r", "src/borg", "-c", "pyproject.toml"]] [tool.coverage.run] branch = true disable_warnings = ["module-not-measured", "no-ctracer"] -source = "src/borg" +source = ["src/borg"] omit = [ "*/borg/__init__.py", "*/borg/__main__.py", diff --git a/requirements.d/development.lock.txt b/requirements.d/development.lock.txt index 832510985..fe384c1de 100644 --- a/requirements.d/development.lock.txt +++ b/requirements.d/development.lock.txt @@ -8,6 +8,7 @@ pkgconfig==1.5.5 tox==4.26.0 pytest==8.4.0 pytest-xdist==3.7.0 +coverage[toml]==7.9.1 pytest-cov==6.2.1 pytest-benchmark==5.1.0 Cython==3.1.2 diff --git a/requirements.d/development.txt b/requirements.d/development.txt index 10d7b55bf..1c2a409fd 100644 --- a/requirements.d/development.txt +++ b/requirements.d/development.txt @@ -8,6 +8,7 @@ pkgconfig tox pytest pytest-xdist +coverage[toml] pytest-cov pytest-benchmark Cython