From: Redouane Kachach Date: Thu, 23 Apr 2026 11:15:19 +0000 (+0200) Subject: mgr/tox: adding coverage target to the main tox.ini X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d16b846a4950de3640c4b4399ed76fb625356c38;p=ceph.git 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 --- 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