Skip to content

Commit 696aea3

Browse files
authored
chore: give every coverage pragma a reason (TS6) (#83)
1 parent b7f337a commit 696aea3

8 files changed

Lines changed: 27 additions & 18 deletions

File tree

‎semvertag/__main__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,5 @@ def main() -> None:
176176
MAIN_APP()
177177

178178

179-
if __name__ == "__main__": # pragma: no cover
179+
if __name__ == "__main__":
180180
main()

‎semvertag/_outcome.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ def to_run_result(outcome: Outcome, *, strategy: str) -> RunResult:
9191
return RunResult(
9292
strategy=strategy, bump=Bump.NONE.value, status=status, tag=None, commit=commit, reason=reason
9393
)
94-
case _: # pragma: no cover
94+
case _: # pragma: no cover - exhaustiveness guard; ty verifies every Outcome is matched
9595
typing.assert_never(outcome)

‎semvertag/_output.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _format_outcome(outcome: Outcome, *, strategy: str) -> str:
6868
return f"No tag created — latest commit is already tagged {tag}."
6969
case NoBump(reason=reason):
7070
return f"No tag created — {reason}"
71-
case _: # pragma: no cover
71+
case _: # pragma: no cover - exhaustiveness guard; ty verifies every Outcome is matched
7272
typing.assert_never(outcome)
7373

7474

‎semvertag/ioc.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _build_current_provider(
7070
http=gitlab_client,
7171
default_branch=settings.default_branch,
7272
)
73-
case _: # pragma: no cover
73+
case _: # pragma: no cover - exhaustiveness guard; ty verifies every ProviderTarget is matched
7474
typing.assert_never(settings.provider_target)
7575

7676

‎tests/_descriptor_gate.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ def main(argv: list[str]) -> None:
116116
sys.stdout.write(f"{argv[1]} shape OK\n")
117117

118118

119-
if __name__ == "__main__": # pragma: no cover
119+
if __name__ == "__main__":
120120
main(sys.argv)

‎tests/integration/test_cli_errors.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import collections.abc
22
import importlib.metadata
3+
import runpy
34
import sys
45
import typing
56
import unittest.mock
@@ -167,3 +168,11 @@ def test_main_entry_point_runs_typer_app_inside_ioc_container(
167168
with pytest.raises(SystemExit) as exc_info:
168169
cli_main.main()
169170
assert exc_info.value.code == 0
171+
172+
173+
def test_python_dash_m_semvertag_runs_the_cli(monkeypatch: pytest.MonkeyPatch) -> None:
174+
monkeypatch.setattr(sys, "argv", ["semvertag", "--version"])
175+
monkeypatch.delitem(sys.modules, "semvertag.__main__")
176+
with pytest.raises(SystemExit) as exc_info:
177+
runpy.run_module("semvertag", run_name="__main__")
178+
assert exc_info.value.code == 0

‎tests/test_ci_descriptor_gate.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"""
88

99
import pathlib
10+
import runpy
11+
import sys
1012
import typing
1113

1214
import pytest
@@ -129,6 +131,16 @@ def test_main_prints_shape_ok_for_valid_descriptor(capsys: pytest.CaptureFixture
129131
assert captured.out == f"{_DESCRIPTOR_PATH} shape OK\n"
130132

131133

134+
def test_module_run_as_script_validates_argv_path(
135+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
136+
) -> None:
137+
monkeypatch.setattr(sys, "argv", ["_descriptor_gate", str(_DESCRIPTOR_PATH)])
138+
monkeypatch.delitem(sys.modules, "tests._descriptor_gate")
139+
runpy.run_module("tests._descriptor_gate", run_name="__main__")
140+
captured: typing.Final = capsys.readouterr()
141+
assert captured.out == f"{_DESCRIPTOR_PATH} shape OK\n"
142+
143+
132144
def test_main_raises_when_argv_length_wrong() -> None:
133145
with pytest.raises(DescriptorGateError, match=r"usage: python -m tests\._descriptor_gate"):
134146
main(["_descriptor_gate"])

‎tests/unit/test_use_case.py‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import semver
66

77
from semvertag._outcome import AlreadyTagged, Created, DryRun, NoBump, NoTags, Outcome
8-
from semvertag._types import Bump, CheckResult, Commit, Tag
8+
from semvertag._types import Bump, Commit, Tag
99
from semvertag._use_case import SemvertagUseCase, _compute_new_version, _select_latest_semver_tag
1010

1111

@@ -62,18 +62,6 @@ def list_tags(self) -> list[Tag]:
6262
def create_tag(self, name: str, commit_sha: str) -> None:
6363
self.create_tag_calls.append((name, commit_sha))
6464

65-
def check_token(self) -> CheckResult: # pragma: no cover
66-
return CheckResult(name="token", status="passed", cause="stub")
67-
68-
def check_scopes(self) -> CheckResult: # pragma: no cover
69-
return CheckResult(name="scopes", status="passed", cause="stub")
70-
71-
def check_project_access(self) -> CheckResult: # pragma: no cover
72-
return CheckResult(name="project_access", status="passed", cause="stub")
73-
74-
def check_protected_tags(self) -> CheckResult: # pragma: no cover
75-
return CheckResult(name="protected_tags", status="passed", cause="stub")
76-
7765

7866
@dataclasses.dataclass(slots=True, kw_only=True)
7967
class _StubStrategy:

0 commit comments

Comments
 (0)