|
16 | 16 | json_dump, json_load, get_font, is_opentype_cff_font,
|
17 | 17 | MSUserFontDirectories, _get_fontconfig_fonts, ttfFontProperty)
|
18 | 18 | from matplotlib import cbook, ft2font, pyplot as plt, rc_context, figure as mfigure
|
19 |
| -from matplotlib.testing import subprocess_run_helper |
| 19 | +from matplotlib.testing import subprocess_run_helper, subprocess_run_for_testing |
20 | 20 |
|
21 | 21 |
|
22 | 22 | has_fclist = shutil.which('fc-list') is not None
|
@@ -280,6 +280,28 @@ def test_fontcache_thread_safe():
|
280 | 280 | subprocess_run_helper(_test_threading, timeout=10)
|
281 | 281 |
|
282 | 282 |
|
| 283 | +def test_lockfilefailure(tmp_path): |
| 284 | + # The logic here: |
| 285 | + # 1. get a temp directory from pytest |
| 286 | + # 2. import matplotlib which makes sure it exists |
| 287 | + # 3. get the cache dir (where we check it is writable) |
| 288 | + # 4. make it not writable |
| 289 | + # 5. try to write into it via font manager |
| 290 | + proc = subprocess_run_for_testing( |
| 291 | + [ |
| 292 | + sys.executable, |
| 293 | + "-c", |
| 294 | + "import matplotlib;" |
| 295 | + "import os;" |
| 296 | + "p = matplotlib.get_cachedir();" |
| 297 | + "os.chmod(p, 0o555);" |
| 298 | + "import matplotlib.font_manager;" |
| 299 | + ], |
| 300 | + env={**os.environ, 'MPLCONFIGDIR': str(tmp_path)}, |
| 301 | + check=True |
| 302 | + ) |
| 303 | + |
| 304 | + |
283 | 305 | def test_fontentry_dataclass():
|
284 | 306 | fontent = FontEntry(name='font-name')
|
285 | 307 |
|
|
0 commit comments