From 9229786d6ef1b810373da7fed5acc9b48ff7ffde Mon Sep 17 00:00:00 2001 From: Wiktor Jelen <35398584+Akinzou@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:23:06 +0100 Subject: [PATCH] docs: "Code Coverage" badge with the pytest logo, next to the README title The owner's call: the measured coverage is shown in the title line, labelled "Code Coverage", rather than in the row of badges below it. The badge still links to the full report on the docs site. Chose pytest's logo over a coverage service's because the tests run under pytest (coverage.py, which has no logo, measures them through pytest-cov), and a service's logo would suggest one this project does not use. Residual risk, accepted by the owner: the badge's alt text joins the H1, so screen readers read "PythonMetaTrader5 Code Coverage". --- CHANGELOG.md | 5 +++-- README.md | 3 +-- scripts/coverage_badge.py | 7 ++++++- tests/unit/test_coverage_badge.py | 4 +++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 848b3ea..89dd26c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ All notable changes to this project are documented here. The format follows ## [Unreleased] ### Added -- A coverage badge in the README, measured by the tests on master and linked - to the full line-by-line report on the documentation site (ADR 0015). +- A "Code Coverage" badge next to the README title, measured by the tests on + master and linked to the full line-by-line report on the documentation site + (ADR 0015). Coverage is 100% of lines and branches, release scripts included, and CI now requires 100%. diff --git a/README.md b/README.md index 251a6d4..2afde8f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -# PythonMetaTrader5 +# PythonMetaTrader5 [![Code Coverage](https://img.shields.io/endpoint?url=https://akinzou.github.io/MetaTrader5-Python/coverage.json)](https://akinzou.github.io/MetaTrader5-Python/coverage/) [![CI](https://github.com/Akinzou/MetaTrader5-Python/actions/workflows/ci.yml/badge.svg)](https://github.com/Akinzou/MetaTrader5-Python/actions/workflows/ci.yml) [![Docs](https://img.shields.io/badge/docs-online-blue?logo=materialformkdocs&logoColor=white)](https://akinzou.github.io/MetaTrader5-Python/) -[![Coverage](https://img.shields.io/endpoint?url=https://akinzou.github.io/MetaTrader5-Python/coverage.json)](https://akinzou.github.io/MetaTrader5-Python/coverage/) [![PyPI](https://img.shields.io/pypi/v/pythonmetatrader5)](https://pypi.org/project/PythonMetaTrader5/) ![Python](https://img.shields.io/badge/python-3.10%2B-blue?logo=python&logoColor=white) ![License](https://img.shields.io/badge/license-CC_BY--NC_4.0-lightgrey.svg) diff --git a/scripts/coverage_badge.py b/scripts/coverage_badge.py index 272774c..d2101fc 100644 --- a/scripts/coverage_badge.py +++ b/scripts/coverage_badge.py @@ -32,9 +32,14 @@ def main(argv: list[str]) -> int: # coverage.py's own display rounding: it never shows 100 for 99.9. badge = { "schemaVersion": 1, - "label": "coverage", + "label": "Code Coverage", "message": f"{totals['percent_covered_display']}%", "color": colour(totals["percent_covered"]), + # pytest's logo: the tests behind the number run under pytest, which + # drives coverage.py through pytest-cov; coverage.py has no logo of its + # own. A coverage service's logo would suggest one this project lacks. + "namedLogo": "pytest", + "logoColor": "white", } target.write_text(json.dumps(badge), encoding="utf-8") print(f"{target}: coverage {badge['message']}") diff --git a/tests/unit/test_coverage_badge.py b/tests/unit/test_coverage_badge.py index 9fc11a1..499ece5 100644 --- a/tests/unit/test_coverage_badge.py +++ b/tests/unit/test_coverage_badge.py @@ -21,9 +21,11 @@ def test_the_badge_shows_the_report_total(tmp_path: Path) -> None: assert badge.main([str(report(tmp_path, "100")), str(out)]) == 0 assert json.loads(out.read_text(encoding="utf-8")) == { "schemaVersion": 1, - "label": "coverage", + "label": "Code Coverage", "message": "100%", "color": "brightgreen", + "namedLogo": "pytest", + "logoColor": "white", }