Skip to content

Commit c0d9e42

Browse files
Fix UTG issues (iteration 1)
1 parent 5e19d33 commit c0d9e42

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

tests/test_readme.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424

2525
def _require_readme() -> str:
26-
assert README_PATH is not None, f"README file not found. Looked for: {', '.join(map(str, README_CANDIDATES))}"
26+
assert README_PATH is not None, (
27+
f"README file not found. Looked for: {', '.join(map(str, README_CANDIDATES))}"
28+
)
2729
return README_PATH.read_text(encoding="utf-8", errors="replace")
2830

2931

@@ -55,15 +57,17 @@ def test_table_of_contents_contains_expected_sections_ordered():
5557
# Ensure each anchor has a corresponding header
5658
for label, anchor in anchors:
5759
header_pattern = rf"^##\s+{re.escape(label)}\s*$"
58-
assert re.search(header_pattern, readme, flags=re.M), f"Header for TOC entry '{label}' not found"
60+
assert re.search(header_pattern, readme, flags=re.M), (
61+
f"Header for TOC entry '{label}' not found"
62+
)
5963

6064

6165
def test_badges_and_links_are_well_formed_urls():
6266
readme = _require_readme()
6367
# Collect all markdown image and link URLs
6468
urls = []
6569
urls += re.findall(r"\!\[[^\]]*\]\((https?://[^)]+)\)", readme) # images
66-
urls += re.findall(r"\[[^\]]*\]\((https?://[^)]+)\)", readme) # links
70+
urls += re.findall(r"\[[^\]]*\]\((https?://[^)]+)\)", readme) # links
6771

6872
assert urls, "No URLs found in README; expected badges/links to be present"
6973

@@ -76,7 +80,9 @@ def test_badges_and_links_are_well_formed_urls():
7680

7781
# Spot-check expected badge providers/domains
7882
assert any("img.shields.io" in u for u in urls), "Shields.io badges should be present"
79-
assert any("github.com/commit-check/commit-check-action" in u for u in urls), "Repository links should be present"
83+
assert any("github.com/commit-check/commit-check-action" in u for u in urls), (
84+
"Repository links should be present"
85+
)
8086

8187

8288
def test_usage_yaml_snippet_contains_expected_github_actions_fields():
@@ -118,7 +124,9 @@ def test_usage_yaml_snippet_contains_expected_github_actions_fields():
118124
r"^\s+pr-comments:\s*\$\{\{\s*github\.event_name\s*==\s*'pull_request'\s*\}\}\s*$",
119125
]
120126
for pattern in expected_lines:
121-
assert re.search(pattern, yaml_text, flags=re.M), f"Missing or malformed line in Usage YAML matching: {pattern}"
127+
assert re.search(pattern, yaml_text, flags=re.M), (
128+
f"Missing or malformed line in Usage YAML matching: {pattern}"
129+
)
122130

123131

124132
def test_optional_inputs_section_lists_all_expected_inputs_with_defaults():
@@ -146,20 +154,25 @@ def test_optional_inputs_section_lists_all_expected_inputs_with_defaults():
146154
section_match = re.search(header_pat + r"([\s\S]+?)(^###\s*`|\Z)", readme, flags=re.M)
147155
assert section_match, f"Section body for `{key}` not found"
148156
section_body = section_match.group(1)
149-
assert re.search(default_pat, section_body, flags=re.M), f"Default for `{key}` should be `{default}`"
157+
assert re.search(default_pat, section_body, flags=re.M), (
158+
f"Default for `{key}` should be `{default}`"
159+
)
150160

151161

152162
def test_merge_base_important_note_present_and_mentions_fetch_depth_zero():
153163
readme = _require_readme()
154-
note_match = re.search(r"###\s*`merge-base`[\s\S]+?>\s*\[\!IMPORTANT\][\s\S]+?fetch-depth:\s*0", readme, flags=re.I)
164+
note_match = re.search(
165+
r"###\s*`merge-base`[\s\S]+?>\s*\[\!IMPORTANT\][\s\S]+?fetch-depth:\s*0", readme, flags=re.I
166+
)
155167
assert note_match, "IMPORTANT note for `merge-base` with fetch-depth: 0 is missing"
156168

157169

158170
def test_pr_comments_important_note_mentions_github_token_and_issue_77():
159171
readme = _require_readme()
160172
assert "### `pr-comments`" in readme
161-
assert re.search(r">\s*\[\!IMPORTANT\][\s\S]+GITHUB_TOKEN[\s\S]+#77", readme), \
162-
"IMPORTANT note for `pr-comments` should mention GITHUB_TOKEN and issue #77"
173+
assert re.search(
174+
r">\s*\[\!IMPORTANT\][\s\S]+GITHUB_TOKEN[\s\S]+#77", readme
175+
), "IMPORTANT note for `pr-comments` should mention GITHUB_TOKEN and issue #77"
163176

164177

165178
def test_used_by_section_contains_expected_orgs_and_structure():
@@ -177,8 +190,9 @@ def test_used_by_section_contains_expected_orgs_and_structure():
177190
assert alt in readme, f"Expected org '{alt}' not mentioned"
178191
assert href in readme, f"Expected org link '{href}' not present"
179192
# Check that avatars come from GitHub's avatars CDN
180-
assert re.search(r'src="https://avatars\.githubusercontent\.com/u/\d+\?s=200&v=4"', readme), \
181-
"Org avatar images should use githubusercontent avatars"
193+
assert re.search(
194+
r'src="https://avatars\.githubusercontent\.com/u/\d+\?s=200&v=4"', readme
195+
), "Org avatar images should use githubusercontent avatars"
182196

183197

184198
def test_badging_section_contains_markdown_and_rst_snippets():
@@ -203,8 +217,9 @@ def test_versioning_and_feedback_sections_present_with_expected_links():
203217
readme = _require_readme()
204218
assert "Versioning follows" in readme and "Semantic Versioning" in readme
205219
# Feedback/issues link
206-
assert re.search(r"\[issues\]\(https://github\.com/commit-check/commit-check/issues\)", readme), \
207-
"Issues link in feedback section is missing"
220+
assert re.search(
221+
r"\[issues\]\(https://github\.com/commit-check/commit-check/issues\)", readme
222+
), "Issues link in feedback section is missing"
208223

209224

210225
def test_all_markdown_links_and_images_have_alt_text_or_label():

0 commit comments

Comments
 (0)