Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa59daf

Browse files
committed
MNT: Move locally defined test marks
1 parent 07f8987 commit fa59daf

File tree

12 files changed

+69
-55
lines changed

12 files changed

+69
-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/marks.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import logging
2+
import shutil
3+
4+
import pytest
5+
6+
import matplotlib.testing
7+
from matplotlib import _get_executable_info, ExecutableNotFoundError
8+
9+
10+
_log = logging.getLogger(__name__)
11+
12+
13+
def _checkdep_usetex():
14+
if not shutil.which("tex"):
15+
_log.warning("usetex mode requires TeX.")
16+
return False
17+
try:
18+
_get_executable_info("dvipng")
19+
except ExecutableNotFoundError:
20+
_log.warning("usetex mode requires dvipng.")
21+
return False
22+
try:
23+
_get_executable_info("gs")
24+
except ExecutableNotFoundError:
25+
_log.warning("usetex mode requires ghostscript.")
26+
return False
27+
return True
28+
29+
30+
needs_ghostscript = pytest.mark.skipif(
31+
"eps" not in matplotlib.testing.compare.converter,
32+
reason="This test needs a ghostscript installation")
33+
needs_lualatex = pytest.mark.skipif(
34+
not matplotlib.testing._check_for_pgf('lualatex'),
35+
reason='lualatex + pgf is required')
36+
needs_pdflatex = pytest.mark.skipif(
37+
not matplotlib.testing._check_for_pgf('pdflatex'),
38+
reason='pdflatex + pgf is required')
39+
needs_usetex = pytest.mark.skipif(
40+
not _checkdep_usetex(),
41+
reason="This test needs a TeX installation")
42+
needs_xelatex = pytest.mark.skipif(
43+
not matplotlib.testing._check_for_pgf('xelatex'),
44+
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.marks 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.marks 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.marks 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.marks 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.marks 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.marks 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.marks 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'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /