Use coverage 7.10.x "patch=subprocess"

.. so we don't need our own code to make subprocess calling
work.
This commit is contained in:
Jeff Epler 2025-08-08 21:49:14 -05:00
parent 92e7ff0e3a
commit 5d484b6eb4
5 changed files with 8 additions and 6 deletions

View file

@ -30,7 +30,7 @@ COVERAGE_INCLUDE=--include "src/**/*.py"
.PHONY: coverage
coverage:
$(Q)$(PYTHON) -mcoverage erase
$(Q)env PYTHONPATH=src $(PYTHON) -mcoverage run --branch -p -m unittest discover -s test
$(Q)env PYTHONPATH=src $(PYTHON) -mcoverage run -p -m unittest discover -s test
$(Q)$(PYTHON) -mcoverage combine -q
$(Q)$(PYTHON) -mcoverage html $(COVERAGE_INCLUDE)
$(Q)$(PYTHON) -mcoverage xml $(COVERAGE_INCLUDE)

View file

@ -53,3 +53,6 @@ module = ["adafruit_datetime"]
follow_untyped_imports = true
[tool.coverage.report]
exclude_also=["if TYPE_CHECKING:"]
[tool.coverage.run]
patch=["subprocess"]
branch=true

View file

@ -5,7 +5,7 @@ adafruit-circuitpython-datetime
beautifulsoup4
build
click
coverage >= 7.1.0
coverage >= 7.10.3
mypy; implementation_name=="cpython"
click>=8.1.5; implementation_name=="cpython"
leapseconddata

View file

@ -91,6 +91,7 @@ def update_iersdata( # noqa: PLR0915
wwvb_data_stamp = datetime.datetime.fromisoformat(meta.attrs["content"]).replace(tzinfo=None).date()
def patch(patch_start: datetime.date, patch_end: datetime.date, val: int) -> None:
assert table_start is not None
off_start = (patch_start - table_start).days
off_end = (patch_end - table_start).days
offsets[off_start:off_end] = [val] * (off_end - off_start)

View file

@ -22,8 +22,6 @@ import wwvb.gen
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 ()
class CLITestCase(unittest.TestCase):
"""Test various CLI commands within wwvbpy"""
@ -34,10 +32,10 @@ class CLITestCase(unittest.TestCase):
return subprocess.check_output(args, stdin=subprocess.DEVNULL, encoding="utf-8", env=env)
def moduleArgs(self, *args: str) -> Sequence[str]:
return (sys.executable, *coverage_add, "-m", *args)
return (sys.executable, "-m", *args)
def moduleOutput(self, *args: str) -> str:
return self.programOutput(sys.executable, *coverage_add, "-m", *args)
return self.programOutput(sys.executable, "-m", *args)
def assertProgramOutput(self, expected: str, *args: str) -> None:
"""Check the output from invoking a program matches the expected"""