From 10eb0e67d35d7f90427445d06d4a7eb5d3e0c31b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 24 Jul 2025 14:03:13 -0500 Subject: [PATCH 1/3] Ensure branch coverage of some `if main` blocks. --- test/testcli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/testcli.py b/test/testcli.py index 2c1cd0c..bf08c6e 100644 --- a/test/testcli.py +++ b/test/testcli.py @@ -14,6 +14,14 @@ import unittest from collections.abc import Sequence from typing import Any +# These imports must remain, even though the module contents are not used directly! +import wwvb.dut1table +import wwvb.gen + +# The asserts below are to help prevent their removal by a linter. +assert wwvb.dut1table.__name__ == "wwvb.dut1table" +assert wwvb.gen.__name__ == "wwvb.gen" + coverage_add = ("-m", "coverage", "run", "--branch", "-p") if "COVERAGE_RUN" in os.environ else () From 9c76dc1a3323c9ca50ab08fe02ce7974520fbf88 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 24 Jul 2025 14:03:21 -0500 Subject: [PATCH 2/3] coverage: move settings into pyproject --- .coveragerc | 15 --------------- pyproject.toml | 2 ++ 2 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 123de6c..0000000 --- a/.coveragerc +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: 2021-2024 Jeff Epler -# -# SPDX-License-Identifier: GPL-3.0-only -[report] -exclude_also = - def __repr__ - if self.debug: - if settings.DEBUG - raise AssertionError - raise NotImplementedError - if 0: - if __name__ == .__main__.: - if TYPE_CHECKING: - class .*\bProtocol\): - @(abc\.)?abstractmethod diff --git a/pyproject.toml b/pyproject.toml index 1d139bd..4f2a2d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,3 +51,5 @@ wwvbtk = "wwvb.wwvbtk:main" [[tool.mypy.overrides]] module = ["adafruit_datetime"] follow_untyped_imports = true +[tool.coverage.report] +exclude_also=["if TYPE_CHECKING:"] From acdb9686193c8410a2f0d145eb5cd29273ef1ad1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 24 Jul 2025 14:04:47 -0500 Subject: [PATCH 3/3] require a newer coverage --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index bb8fe6c..8106670 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,7 +5,7 @@ adafruit-circuitpython-datetime beautifulsoup4 build click -coverage +coverage >= 7.1.0 mypy; implementation_name=="cpython" click>=8.1.5; implementation_name=="cpython" leapseconddata