Commit b850021
authored
test(docs[sphinx_fonts]) add tests and fix download failure bugs (#1023)
why: sphinx_fonts.py had zero test coverage, and two latent bugs were
discovered during test development — font-face entries emitted for
failed downloads, and partial files poisoning the cache.
what:
Test suite (21 functions, 545 lines)
- _cache_dir: path construction
- _cdn_url: parametrized URL formatting, template structure
- _download_font: cached hit, success, URLError, OSError, partial cleanup
- _on_builder_inited: non-html skip, empty fonts, font processing,
download failure skip, explicit subset, preload match/no-match,
fallbacks and CSS variables
- _on_html_page_context: with/without app attributes
- setup: return metadata, config values, event connections
Bug fixes in sphinx_fonts.py
- Move font_faces.append() inside if _download_font() block to skip
font-face entries when download fails (was emitting CSS pointing to
missing files)
- Add dest.unlink() in except block to remove partial .woff2 files
left by interrupted downloads (was poisoning cache)
Docstrings
- Add docstrings to SetupDict and setup() for ruff D101/D1031 parent 9c0caa1 commit b850021
2 files changed
Lines changed: 558 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| |||
135 | 139 | | |
136 | 140 | | |
137 | 141 | | |
| 142 | + | |
138 | 143 | | |
139 | 144 | | |
140 | 145 | | |
| |||
0 commit comments