Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

docs: the press counts live in the Dutch card alt text too

xbsheng6c870fcfc4ee
diff --git a/docs/workflows/press.md b/docs/workflows/press.md
index f9536468f..8fe112187 100644
--- a/docs/workflows/press.md
+++ b/docs/workflows/press.md
@@ -5,9 +5,10 @@
1. Add a row `| Outlet | [Headline](<url>) | Date |` to the right country section of `docs/PRESS.md`, in the
headline's own language. The link must open and show the article: no syndicated copies, no auto-generated
listings, nothing that cannot be checked.
-2. Update the counts in all four places `tests/test_press_counts.py` checks: the `docs/PRESS.md` intro line,
- its index line, the README card's alt text ("and N more: N articles from N countries") and `MORE` in
- `tools/readme_featured.py`. Redrawing `docs/featured.png` and `docs/card.jpg` needs Pillow, which the
+2. Update the counts in all five places `tests/test_press_counts.py` checks: the `docs/PRESS.md` intro line,
+ its index line, the card's alt text in `README.md` ("and N more: N articles from N countries"), the same
+ numbers in the Dutch alt text of that card in `README.nl.md` ("nog N media: N artikelen uit N landen"), and
+ `MORE` in `tools/readme_featured.py`. Redrawing `docs/featured.png` and `docs/card.jpg` needs Pillow, which the
performance requirements install:
`tools/venv/bin/pip install -r tools/requirements-perf.txt`, then
`tools/venv/bin/python -I tools/readme_featured.py Fredoka.ttf docs/featured.png` and
diff --git a/tests/test_press_counts.py b/tests/test_press_counts.py
index 8b6c92873..2f858f75b 100644
--- a/tests/test_press_counts.py
+++ b/tests/test_press_counts.py
@@ -1,9 +1,10 @@
-"""Keeps the press numbers in docs/PRESS.md, the README card and the card source in step.
+"""Keeps the press numbers in docs/PRESS.md, the README cards and the card source in step.
-The article total is written in four places: the PRESS.md intro, its per-country index line,
-the README alt text and tools/readme_featured.py (which draws the line onto docs/featured.png).
-Adding one article by hand means editing all four; this checks they agree, so a PR that adds a
-row and forgets the counts fails here instead of shipping a card that says 73 over a list of 74.
+The article total is written in five places: the PRESS.md intro, its per-country index line, the
+alt text of the card in README.md, the alt text of the same card in README.nl.md (in Dutch), and
+tools/readme_featured.py (which draws the line onto docs/featured.png). Adding one article by hand
+means editing all five; this checks they agree, so a PR that adds a row and forgets the counts
+fails here instead of shipping a card that says 73 over a list of 74.
Run from the repository root: python3 -m unittest discover -s tests -v
"""
@@ -16,12 +17,26 @@ ROOT = Path(__file__).resolve().parents[1]
PRESS = ROOT / "docs" / "PRESS.md"
README = ROOT / "README.md"
FEATURED = ROOT / "tools" / "readme_featured.py"
+PRESS_RECIPE = ROOT / "docs" / "workflows" / "press.md"
LATAM = "Latin America (Spanish-language)"
ONLINE = "Online (newsletters, blogs, AI news)"
ROW = re.compile(r"^\| (?!Outlet\b)(?!--)")
LINK = re.compile(r"\[[^\]]+\]\((https?://[^)]+)\)")
TOC_ENTRY = re.compile(r"\[([^\]]+)\]\(#[^)]+\)&nbsp;(\d+)")
+# The card image the numbers are drawn on, wherever a README shows it: README.md in English and
+# README.nl.md in Dutch. The words around the numbers are translated; the numbers are not.
+CARD_ALT = re.compile(r'src="docs/card\.jpg"[^>]*?alt="([^"]*)"')
+
+
+def card_alt_texts():
+ """{file name: alt text} for every README whose card image carries an alt text."""
+ out = {}
+ for path in sorted(ROOT.glob("README*.md")):
+ match = CARD_ALT.search(path.read_text(encoding="utf-8"))
+ if match:
+ out[path.name] = match.group(1)
+ return out
def sections():
@@ -107,6 +122,31 @@ class PressCountsTest(unittest.TestCase):
self.assertEqual(countries, self.numbers["countries"], "README alt text and docs/PRESS.md disagree on the country count")
self.assertEqual(more, self.numbers["total"] - len(logos()), "README alt text and the logos in tools/readme_featured.py disagree on the '+N more'")
+ def test_every_readme_card_states_the_same_numbers(self):
+ # The card is in README.md and in README.nl.md, and both alt texts state the total, the
+ # country count and the "+N more" - in English and in Dutch. Only the English one was
+ # checked, so the press commit that took the list to 296 articles had to change the Dutch
+ # alt text by hand as well (6cc2fdc9), and a PR written from docs/workflows/press.md left
+ # the Dutch front page claiming an older count.
+ alts = card_alt_texts()
+ self.assertLessEqual({"README.md", "README.nl.md"}, set(alts),
+ "README.md and README.nl.md no longer show docs/card.jpg with an alt text")
+ numbers = (("article total", self.numbers["total"]),
+ ("country count", self.numbers["countries"]),
+ ("'+N more'", self.numbers["total"] - len(logos())))
+ for name, alt in alts.items():
+ for what, number in numbers:
+ with self.subTest(readme=name, number=what):
+ self.assertRegex(alt, rf"(?<!\d){number}(?!\d)",
+ f"{name}'s card alt text does not state the {what} ({number}) "
+ f"that docs/PRESS.md and tools/readme_featured.py carry")
+
+ def test_the_press_recipe_names_every_place_the_counts_live(self):
+ step = PRESS_RECIPE.read_text(encoding="utf-8").split("\n2. ")[1].split("\n3. ")[0]
+ for name in ("README.md", "README.nl.md"):
+ with self.subTest(readme=name):
+ self.assertIn(name, step, f"docs/workflows/press.md step 2 does not name {name}")
+
def test_the_card_source_draws_the_same_numbers(self):
more = re.search(r'^MORE = "(.*)"$', FEATURED.read_text(encoding="utf-8"), re.M)
self.assertIsNotNone(more, "tools/readme_featured.py no longer has a MORE line")