"""Tests that a Cask file exists for every font with installable files.""" import pytest from tests.conftest import CASKS_DIR, FONT_FILES_DIR, get_font_dir_names INSTALLABLE_EXTS = (".ttf", ".otf", ".ttc") def _has_installable_fonts(font_name: str) -> bool: font_dir = FONT_FILES_DIR / font_name for ext in INSTALLABLE_EXTS: pattern = f"*{ext}" if any((font_dir / "ttf").glob(pattern)) or any((font_dir / "otf").glob(pattern)): return True return False @pytest.mark.parametrize("font_name", get_font_dir_names()) def test_cask_file_exists(font_name): """Casks/font-.rb exists for each font folder with installable fonts.""" if not _has_installable_fonts(font_name): pytest.skip(f"{font_name} has no installable font files (TTF/OTF/TTC)") cask_path = CASKS_DIR / f"{font_name}.rb" assert cask_path.is_file(), ( f"Missing cask for {font_name}: expected {cask_path}" )