_markers.py 1.4 KB

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