Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 835d97b

Browse files
committed
Enable more font_manager tests to be run locally.
- test_utf16m_sfnt can also be run on non-Windows, which may *still* have seguisbi.ttf installed. In any case the test is skipped cleanly if the font is not present (I replaced the xfail by a skip for consistency with test_find_ttc, and in any case it's clearly a case of "the setup doesn't allow the test to be run", not "the test ran and failed"). - test_find_ttc can be run on non-Travis as long as the qwy-zenhei.ttc is present -- again, we just need to quit cleanly if it is not.
1 parent d311b9b commit 835d97b

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

lib/matplotlib/tests/test_font_manager.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,24 @@ def test_hinting_factor(factor):
9595
rtol=0.1)
9696

9797

98-
@pytest.mark.skipif(sys.platform != "win32",
99-
reason="Need Windows font to test against")
10098
def test_utf16m_sfnt():
101-
segoe_ui_semibold = None
102-
for f in fontManager.ttflist:
99+
try:
103100
# seguisbi = Microsoft Segoe UI Semibold
104-
if f.fname[-12:] == "seguisbi.ttf":
105-
segoe_ui_semibold = f
106-
break
101+
entry = next(entry for entry in fontManager.ttflist
102+
if Path(entry.fname).name == "seguisbi.ttf")
103+
except StopIteration:
104+
pytest.skip("Couldn't find font to test against.")
107105
else:
108-
pytest.xfail(reason="Couldn't find font to test against.")
109-
110-
# Check that we successfully read the "semibold" from the font's
111-
# sfnt table and set its weight accordingly
112-
assert segoe_ui_semibold.weight == "semibold"
106+
# Check that we successfully read "semibold" from the font's sfnt table
107+
# and set its weight accordingly.
108+
assert entry.weight == "semibold"
113109

114110

115-
@pytest.mark.xfail(not (os.environ.get("TRAVIS") and sys.platform == "linux"),
116-
reason="Font may be missing.")
117111
def test_find_ttc():
118112
fp = FontProperties(family=["WenQuanYi Zen Hei"])
119113
if Path(findfont(fp)).name != "wqy-zenhei.ttc":
114+
if not os.environ.get("TRAVIS") or sys.platform != "linux":
115+
pytest.skip("Font may be missing")
120116
# Travis appears to fail to pick up the ttc file sometimes. Try to
121117
# rebuild the cache and try again.
122118
fm._rebuild()

0 commit comments

Comments
 (0)