8000 Try forcing font cache rebuild in flaky ttc test. (#13331) · matplotlib/matplotlib@623b789 · GitHub
[go: up one dir, main page]

Skip to content

Commit 623b789

Browse files
anntzerdstansby
authored andcommitted
Try forcing font cache rebuild in flaky ttc test. (#13331)
Looks like Travis is correctly installing the font (it is present as /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc), but perhaps it is using an outdated font cache?
1 parent a6d57b5 commit 623b789

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/matplotlib/tests/test_font_manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import numpy as np
99
import pytest
1010

11+
from matplotlib import font_manager as fm
1112
from matplotlib.font_manager import (
1213
findfont, findSystemFonts, FontProperties, fontManager, json_dump,
1314
json_load, get_font, get_fontconfig_fonts, is_opentype_cff_font,
@@ -114,12 +115,11 @@ def test_utf16m_sfnt():
114115
reason="Font may be missing.")
115116
def test_find_ttc():
116117
fp = FontProperties(family=["WenQuanYi Zen Hei"])
117-
font = findfont(fp)
118-
if Path(font).name != "wqy-zenhei.ttc":
119-
# This test appears to be flaky on Travis... investigate it.
120-
print("system fonts:")
121-
print(*findSystemFonts(), sep="\n")
122-
pytest.fail("Failed to find wqy-zenhei.ttc")
118+
if Path(findfont(fp)).name != "wqy-zenhei.ttc":
119+
# Travis appears to fail to pick up the ttc file sometimes. Try to
120+
# rebuild the cache and try again.
121+
fm._rebuild()
122+
assert Path(findfont(fp)).name == "wqy-zenhei.ttc"
123123

124124
fig, ax = plt.subplots()
125125
ax.text(.5, .5, "\N{KANGXI RADICAL DRAGON}", fontproperties=fp)

0 commit comments

Comments
 (0)
0