chore: add test for changelog markdown headers

This commit is contained in:
aclist committed 2026-08-20 13:58:05 +09:00
1 parent 203cf0da7f
commit 05fab5774e
1 file changed
+27 -13
+27 -13
View File
@@ -1,20 +1,34 @@
import re
import pytest import pytest
from importlib import resources from pathlib import Path
from dzgui.const.constants import APP_NAME_LOWER, CHANGELOG_PATH
@pytest.fixture @pytest.fixture
def changelog(): def changelog(request) -> None:
path = resources.files(APP_NAME_LOWER).joinpath(CHANGELOG_PATH) root = request.config.rootpath
return path changelog = Path(root).joinpath("CHANGELOG.md").read_text()
return changelog
def test_headings(changelog): def count_hash(line: str) -> int:
with open(changelog, "r") as f: cnt = 0
lines = f.readlines() for c in line:
for line in lines: if c == "#":
if line.startswith("#"): cnt += 1
pass return cnt
# TODO: use regex
pass
@pytest.mark.FOO
def test_changelog_prefix(changelog) -> None:
r = r".*(\[.*\]).*"
lines = changelog.splitlines()
sort = sorted(lines)
match = [line for line in sort if line.startswith("#")]
for m in match:
if "Changelog" in m:
assert count_hash(m) == 1
elif re.match(r, m) is not None:
assert count_hash(m) == 2
else:
assert count_hash(m) == 3