|
| 1 | +""" |
| 2 | +pytest markers for the internal Matplotlib test suite. |
| 3 | +""" |
| 4 | + |
| 5 | +import logging |
| 6 | +import shutil |
| 7 | + |
| 8 | +import pytest |
| 9 | + |
| 10 | +import matplotlib.testing |
| 11 | +from matplotlib import _get_executable_info, ExecutableNotFoundError |
| 12 | + |
| 13 | + |
| 14 | +_log = logging.getLogger(__name__) |
| 15 | + |
| 16 | + |
| 17 | +def _checkdep_usetex(): |
| 18 | + if not shutil.which("tex"): |
| 19 | + _log.warning("usetex mode requires TeX.") |
| 20 | + return False |
| 21 | + try: |
| 22 | + _get_executable_info("dvipng") |
| 23 | + except ExecutableNotFoundError: |
| 24 | + _log.warning("usetex mode requires dvipng.") |
| 25 | + return False |
| 26 | + try: |
| 27 | + _get_executable_info("gs") |
| 28 | + except ExecutableNotFoundError: |
| 29 | + _log.warning("usetex mode requires ghostscript.") |
| 30 | + return False |
| 31 | + return True |
| 32 | + |
| 33 | + |
| 34 | +needs_ghostscript = pytest.mark.skipif( |
| 35 | + "eps" not in matplotlib.testing.compare.converter, |
| 36 | + reason="This test needs a ghostscript installation") |
| 37 | +needs_lualatex = pytest.mark.skipif( |
| 38 | + not matplotlib.testing._check_for_pgf('lualatex'), |
| 39 | + reason='lualatex + pgf is required') |
| 40 | +needs_pdflatex = pytest.mark.skipif( |
| 41 | + not matplotlib.testing._check_for_pgf('pdflatex'), |
| 42 | + reason='pdflatex + pgf is required') |
| 43 | +needs_usetex = pytest.mark.skipif( |
| 44 | + not _checkdep_usetex(), |
| 45 | + reason="This test needs a TeX installation") |
| 46 | +needs_xelatex = pytest.mark.skipif( |
| 47 | + not matplotlib.testing._check_for_pgf('xelatex'), |
| 48 | + reason='xelatex + pgf is required') |
0 commit comments