From d16b846a4950de3640c4b4399ed76fb625356c38 Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Thu, 23 Apr 2026 13:15:19 +0200 Subject: [PATCH] mgr/tox: adding coverage target to the main tox.ini Let's add a coverage target so we can measure this metric for mgr modules. Usage examples: Run coverage for a single module (percentages only): tox -e coverage -- cephadm tox -e coverage -- smb Show uncovered line numbers: COVERAGE_REPORT=term-missing tox -e coverage -- cephadm Generate a visual HTML report: COVERAGE_REPORT=html tox -e coverage -- cephadm firefox htmlcov/index.html Signed-off-by: Redouane Kachach --- src/pybind/mgr/tox.ini | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 94f7b8119a55..46892ade74e6 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -7,6 +7,7 @@ envlist = check-black check-isort py3 + coverage skipsdist = true skip_missing_interpreters = true @@ -45,6 +46,12 @@ addopts = --recursive \ --ignore-local-config +[coverage:report] +omit = + */tests/* + */test_*.py + */templates/* + [testenv] setenv = UNITTEST = true @@ -66,6 +73,23 @@ commands = pytest {posargs:cephadm/tests/test_ssh.py} +[testenv:coverage] +setenv = + UNITTEST = true + PYTHONPATH = $PYTHONPATH:.. +deps = + {[base]deps} + pytest-cov +# Default: percentages only +# To show uncovered line numbers: +# COVERAGE_REPORT=term-missing tox -e coverage -- +# To generate a nice html with visual uncovered line numbers: +# COVERAGE_REPORT=html tox -e coverage -- +# htmlcov/index.html +commands = + pytest --cov={posargs:.} --cov-report={env:COVERAGE_REPORT:term} {posargs:.} + + [testenv:{,py37-,py38-,py39-,py310-}mypy] setenv = MYPYPATH = {toxinidir}/..:{toxinidir}/../../python-common -- 2.47.3