MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_user_fonts_linux

Function test_user_fonts_linux

lib/matplotlib/tests/test_font_manager.py:206–228  ·  view source on GitHub ↗
(tmpdir, monkeypatch)

Source from the content-addressed store, hash-verified

204@pytest.mark.skipif(sys.platform != 'linux' or not has_fclist,
205 reason='only Linux with fontconfig installed')
206def test_user_fonts_linux(tmpdir, monkeypatch):
207 font_test_file = 'mpltest.ttf'
208
209 # Precondition: the test font should not be available
210 fonts = findSystemFonts()
211 if any(font_test_file in font for font in fonts):
212 pytest.skip(f'{font_test_file} already exists in system fonts')
213
214 # Prepare a temporary user font directory
215 user_fonts_dir = tmpdir.join('fonts')
216 user_fonts_dir.ensure(dir=True)
217 shutil.copyfile(Path(__file__).parent / 'data' / font_test_file,
218 user_fonts_dir.join(font_test_file))
219
220 with monkeypatch.context() as m:
221 m.setenv('XDG_DATA_HOME', str(tmpdir))
222 _get_fontconfig_fonts.cache_clear()
223 # Now, the font should be available
224 fonts = findSystemFonts()
225 assert any(font_test_file in font for font in fonts)
226
227 # Make sure the temporary directory is no longer cached.
228 _get_fontconfig_fonts.cache_clear()
229
230
231def test_addfont_as_path(monkeypatch):

Callers

nothing calls this directly

Calls 3

findSystemFontsFunction · 0.90
PathClass · 0.85
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…