homebrew-fonts/tests/conftest.py
Matt Troutman 76743cdc4d
Convert from Homebrew Formulae to Casks for font installation
Formulae can't install to ~/Library/Fonts/ due to Homebrew sandboxing.
Casks have a built-in `font` artifact that handles this automatically.

- Replace Formula/ with Casks/ directory
- Rewrite generator to produce cask files instead of formulae
- Add .ttc (TrueType Collection) support
- Update all tests for cask format
- Update CLI and documentation
- Fonts with no installable files (TTF/OTF/TTC) are skipped

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 21:38:59 -06:00

42 lines
1.2 KiB
Python

"""Shared fixtures and repo paths for font tap tests."""
from pathlib import Path
import pytest
# Repo root: directory containing font_files/ and Casks/
REPO_ROOT = Path(__file__).resolve().parent.parent
FONT_FILES_DIR = REPO_ROOT / "font_files"
CASKS_DIR = REPO_ROOT / "Casks"
REQUIRED_SUBDIRS = ("ttf", "otf", "web", "other_files")
WEB_EXTENSIONS = (".woff", ".woff2", ".eot", ".svg")
def get_font_dir_names():
"""Return sorted list of font-* directory names in font_files/ (single source of truth)."""
if not FONT_FILES_DIR.exists():
return []
return sorted(
d.name for d in FONT_FILES_DIR.iterdir() if d.is_dir() and d.name.startswith("font-")
)
@pytest.fixture(scope="session")
def repo_root():
return REPO_ROOT
@pytest.fixture(scope="session")
def font_dir_names():
"""All font folder names (font-<name>) from font_files/."""
names = get_font_dir_names()
assert names, "No font-* directories found in font_files/"
return names
@pytest.fixture(scope="session")
def cask_paths():
"""All Casks/font-*.rb paths that exist."""
if not CASKS_DIR.exists():
return []
return sorted(CASKS_DIR.glob("font-*.rb"))