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

Function test_user_fonts_win32

lib/matplotlib/tests/test_font_manager.py:252–276  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250
251@pytest.mark.skipif(sys.platform != 'win32', reason='Windows only')
252def test_user_fonts_win32():
253 if not (os.environ.get('APPVEYOR') or os.environ.get('TF_BUILD')):
254 pytest.xfail("This test should only run on CI (appveyor or azure) "
255 "as the developer's font directory should remain "
256 "unchanged.")
257 pytest.xfail("We need to update the registry for this test to work")
258 font_test_file = 'mpltest.ttf'
259
260 # Precondition: the test font should not be available
261 fonts = findSystemFonts()
262 if any(font_test_file in font for font in fonts):
263 pytest.skip(f'{font_test_file} already exists in system fonts')
264
265 user_fonts_dir = MSUserFontDirectories[0]
266
267 # Make sure that the user font directory exists (this is probably not the
268 # case on Windows versions < 1809)
269 os.makedirs(user_fonts_dir)
270
271 # Copy the test font to the user font directory
272 shutil.copy(Path(__file__).parent / 'data' / font_test_file, user_fonts_dir)
273
274 # Now, the font should be available
275 fonts = findSystemFonts()
276 assert any(font_test_file in font for font in fonts)
277
278
279def _model_handler(_):

Callers

nothing calls this directly

Calls 4

findSystemFontsFunction · 0.90
PathClass · 0.85
getMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…