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

Skip to content

Commit 1341ad5

Browse files
authored
Merge pull request #23342 from tacaswell/fix/font_list
FIX: make sure addFont test removes the test font
2 parents dff87ce + 6b901fe commit 1341ad5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/tests/test_font_manager.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,16 @@ def test_addfont_as_path():
180180
"""Smoke test that addfont() accepts pathlib.Path."""
181181
font_test_file = 'mpltest.ttf'
182182
path = Path(__file__).parent / font_test_file
183-
fontManager.addfont(path)
183+
try:
184+
fontManager.addfont(path)
185+
added, = [font for font in fontManager.ttflist
186+
if font.fname.endswith(font_test_file)]
187+
fontManager.ttflist.remove(added)
188+
finally:
189+
to_remove = [font for font in fontManager.ttflist
190+
if font.fname.endswith(font_test_file)]
191+
for font in to_remove:
192+
fontManager.ttflist.remove(font)
184193

185194

186195
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows only')

0 commit comments

Comments
 (0)