8000 Merge pull request #23045 from oscargus/movedecorators · matplotlib/matplotlib@1e22895 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e22895

Browse files
authored
Merge pull request #23045 from oscargus/movedecorators
MNT: Merge locally defined test marks
2 parents b7ca8bb + 3154eb0 commit 1e22895

File tree

12 files changed

+73
-55
lines changed

12 files changed

+73
-55
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
``checkdep_usetex`` deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
This method was only intended to disable tests in case no latex install was
5+
found. As such, it is considered to be private and for internal use only.
6+
7+
Please vendor the code if you need this.

lib/matplotlib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False):
434434
raise ValueError("Unknown executable: {!r}".format(name))
435435

436436

437+
@_api.deprecated("3.6", alternative="Vendor the code")
437438
def checkdep_usetex(s):
438439
if not s:
439440
return False

lib/matplotlib/testing/_markers.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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')

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import re
22

33
from matplotlib import path, transforms
4-
from matplotlib.testing import _check_for_pgf
54
from matplotlib.backend_bases import (
65
FigureCanvasBase, LocationEvent, MouseButton, MouseEvent,
76
NavigationToolbar2, RendererBase)
87
from matplotlib.figure import Figure
8+
from matplotlib.testing._markers import needs_xelatex
99
import matplotlib.pyplot as plt
1010

1111
import numpy as np
1212
import pytest
1313

14-
needs_xelatex = pytest.mark.skipif(not _check_for_pgf('xelatex'),
15-
reason='xelatex + pgf is required')
16-
1714

1815
def test_uses_per_path():
1916
id = transforms.Affine2D()

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@
99
import pytest
1010

1111
import matplotlib as mpl
12-
from matplotlib import pyplot as plt, checkdep_usetex, rcParams
12+
from matplotlib import pyplot as plt, rcParams
1313
from matplotlib.cbook import _get_data_path
1414
from matplotlib.ft2font import FT2Font
1515
from matplotlib.font_manager import findfont, FontProperties
1616
from matplotlib.backends._backend_pdf_ps import get_glyphs_subset
1717
from matplotlib.backends.backend_pdf import PdfPages
1818
from matplotlib.patches import Rectangle
1919
from matplotlib.testing.decorators import check_figures_equal, image_comparison
20-
21-
22-
needs_usetex = pytest.mark.skipif(
23-
not checkdep_usetex(True),
24-
reason="This test needs a TeX installation")
20+
from matplotlib.testing._markers import needs_usetex
2521

2622

2723
@image_comparison(['pdf_use14corefonts.pdf'])

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,13 @@
1212
from matplotlib.testing import _has_tex_package, _check_for_pgf
1313
from matplotlib.testing.compare import compare_images, ImageComparisonFailure
1414
from matplotlib.backends.backend_pgf import PdfPages, _tex_escape
15-
from matplotlib.testing.decorators import (_image_directories,
16-
check_figures_equal,
17-
image_comparison)
15+
from matplotlib.testing.decorators import (
16+
_image_directories, check_figures_equal, image_comparison)
17+
from matplotlib.testing._markers import (
18+
needs_ghostscript, needs_lualatex, needs_pdflatex, needs_xelatex)
1819

19-
baseline_dir, result_dir = _image_directories(lambda: 'dummy func')
2020

21-
needs_xelatex = pytest.mark.skipif(not _check_for_pgf('xelatex'),
22-
reason='xelatex + pgf is required')
23-
needs_pdflatex = pytest.mark.skipif(not _check_for_pgf('pdflatex'),
24-
reason='pdflatex + pgf is required')
25-
needs_lualatex = pytest.mark.skipif(not _check_for_pgf('lualatex'),
26-
reason='lualatex + pgf is required')
27-
needs_ghostscript = pytest.mark.skipif(
28-
"eps" not in mpl.testing.compare.converter,
29-
reason="This test needs a ghostscript installation")
21+
baseline_dir, result_dir = _image_directories(lambda: 'dummy func')
3022

3123

3224
def compare_figure(fname, savefig_kwargs={}, tol=0):

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@
1111
from matplotlib.figure import Figure
1212
from matplotlib.patches import Ellipse
1313
from matplotlib.testing.decorators import check_figures_equal, image_comparison
14+
from matplotlib.testing._markers import needs_ghostscript, needs_usetex
1415
import matplotlib as mpl
1516
import matplotlib.pyplot as plt
1617

17-
needs_ghostscript = pytest.mark.skipif(
18-
"eps" not in mpl.testing.compare.converter,
19-
reason="This test needs a ghostscript installation")
20-
needs_usetex = pytest.mark.skipif(
21-
not mpl.checkdep_usetex(True),
22-
reason="This test needs a TeX installation")
23-
2418

2519
# This tests tends to hit a TeX cache lock on AppVeyor.
2620
@pytest.mark.flaky(reruns=3)

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@
44
import xml.parsers.expat
55

66
import numpy as np
7-
import pytest
87

98
import matplotlib as mpl
109
from matplotlib.figure import Figure
1110
from matplotlib.text import Text
1211
import matplotlib.pyplot as plt
13-
from matplotlib.testing.decorators import image_comparison, check_figures_equal
14-
15-
16-
needs_usetex = pytest.mark.skipif(
17-
not mpl.checkdep_usetex(True),
18-
reason="This test needs a TeX installation")
12+
from matplotlib.testing.decorators import check_figures_equal, image_comparison
13+
from matplotlib.testing._markers import needs_usetex
1914

2015

2116
def test_visibility():

lib/matplotlib/tests/test_determinism.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@
1111
import matplotlib as mpl
1212
import matplotlib.testing.compare
1313
from matplotlib import pyplot as plt
14-
15-
16-
needs_ghostscript = pytest.mark.skipif(
17-
"eps" not in mpl.testing.compare.converter,
18-
reason="This test needs a ghostscript installation")
19-
needs_usetex = pytest.mark.skipif(
20-
not mpl.checkdep_usetex(True),
21-
reason="This test needs a TeX installation")
14+
from matplotlib.testing._markers import needs_ghostscript, needs_usetex
2215

2316

2417
def _save_figure(objects='mhi', fmt="pdf", usetex=False):

lib/matplotlib/tests/test_legend.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77

88
from matplotlib.testing.decorators import image_comparison
9+
from matplotlib.testing._markers import needs_usetex
910
import matplotlib.pyplot as plt
1011
import matplotlib as mpl
1112
import matplotlib.transforms as mtransforms
@@ -764,9 +765,7 @@ def test_alpha_handles():
764765
assert lh.get_edgecolor()[:-1] == hh[1].get_edgecolor()[:-1]
765766

766767

767-
@pytest.mark.skipif(
768-
not mpl.checkdep_usetex(True),
769-
reason="This test needs a TeX installation")
768+
@needs_usetex
770769
def test_usetex_no_warn(caplog):
771770
mpl.rcParams['font.family'] = 'serif'
772771
mpl.rcParams['font.serif'] = 'Computer Modern'

lib/matplotlib/tests/test_text.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
import matplotlib.pyplot as plt
1414
import matplotlib.transforms as mtransforms
1515
from matplotlib.testing.decorators import check_figures_equal, image_comparison
16+
from matplotlib.testing._markers import needs_usetex
1617
from matplotlib.text import Text
1718

1819

19-
needs_usetex = pytest.mark.skipif(
20-
not mpl.checkdep_usetex(True),
21-
reason="This test needs a TeX installation")
22-
23-
2420
@image_comparison(['font_styles'])
2521
def test_font_styles():
2622

lib/matplotlib/tests/test_usetex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from matplotlib import dviread
88
from matplotlib.testing import _has_tex_package
99
from matplotlib.testing.decorators import check_figures_equal, image_comparison
10+
from matplotlib.testing._markers import needs_usetex
1011
import matplotlib.pyplot as plt
1112

1213

13-
if not mpl.checkdep_usetex(True):
14-
pytestmark = pytest.mark.skip('Missing TeX of Ghostscript or dvipng')
14+
pytestmark = needs_usetex
1515

1616

1717
@image_comparison(

0 commit comments

Comments
 (0)
0