From 7bfd36d89ce35f1ab79cb2dd4e7523f3a354047c Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 25 Jun 2026 15:43:07 +0200 Subject: [PATCH] build(test): add pytest-cov for xdist-compatible coverage `coverage run` only instruments the main process. With pytest-xdist, test workers are spawned as separate processes and their coverage is lost. Replace `coverage run -m pytest` with `pytest --cov`, which uses pytest-cov to instrument xdist workers correctly. Follow-up to #1218. Co-Authored-By: Claude Signed-off-by: Christian Heimes --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0235c135..17df0a16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,7 @@ mypy = [ test = [ "coverage[toml]!=4.4,>=4.0", "pytest", + "pytest-cov", "pytest-xdist", "requests-mock", "spdx-tools", @@ -231,7 +232,7 @@ features = ["test"] # {args:tests} allows passing arguments to specify which tests to run [tool.hatch.envs.test.scripts] -test = "python -m coverage run -m pytest --log-level DEBUG -vv {args:tests}" +test = "python -m pytest --cov --log-level DEBUG -vv {args:tests}" coverage-erase = "coverage erase" coverage-combine = "coverage combine" coverage-report = ["coverage combine", "coverage report --format=markdown | tee coverage-report-$(date +%Y%m%d-%H%M%S).md"]