(tmpdir, monkeypatch)
| 204 | @pytest.mark.skipif(sys.platform != 'linux' or not has_fclist, |
| 205 | reason='only Linux with fontconfig installed') |
| 206 | def 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 | |
| 231 | def test_addfont_as_path(monkeypatch): |
nothing calls this directly
no test coverage detected
searching dependent graphs…