translation_path = by_slug.get((other_lang, slug))
try:
fm, _ = parse_frontmatter(path)
- except (ValueError, Exception):
+ except (ValueError, OSError):
fm = {}
articles.append(Article(
slug=slug,
assert art.has_translation is False
assert art.translation_path is None
+def test_scan_tolerates_corrupt_frontmatter(tmp_path):
+ p = tmp_path / "content" / "it" / "articles" / "broken"
+ p.mkdir(parents=True)
+ (p / "index.md").write_text("no frontmatter delimiters here\n")
+ articles = scan_articles(tmp_path)
+ art = next(a for a in articles if a.slug == "broken")
+ assert art.frontmatter == {}
+
def test_scan_parses_frontmatter(tmp_path):
_make_article(tmp_path, "it", "con-fm", 'tags = ["linux"]\n')
articles = scan_articles(tmp_path)