8000 BUG: fix test error when ghostscript not installed · matplotlib/matplotlib@bd852df · GitHub
[go: up one dir, main page]

Skip to content

Commit bd852df

Browse files
committed
BUG: fix test error when ghostscript not installed
Confusingly checkdep_ghostscript returns a tuple rather than a bool, so we need to check an element of the tuple to see whether ghostscript is installed. Put the test into a decorator in case we need it for another test.
1 parent e76996f commit bd852df

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@
77
import re
88

99
import six
10-
from nose.plugins.skip import SkipTest
1110

1211
import matplotlib
1312
import matplotlib.pyplot as plt
14-
from matplotlib.testing.decorators import cleanup
13+
from matplotlib.testing.decorators import cleanup, knownfailureif
14+
15+
16+
needs_ghostscript = knownfailureif(
17+
matplotlib.checkdep_ghostscript()[0] is None,
18+
"This test needs a ghostscript installation")
19+
20+
21+
needs_tex = knownfailureif(
22+
not matplotlib.checkdep_tex(),
23+
"This test needs a TeX installation")
1524

1625

1726
def _test_savefig_to_stringio(format='ps'):
@@ -50,18 +59,15 @@ def test_savefig_to_stringio():
5059

5160

5261
@cleanup
62+
@needs_ghostscript
5363
def test_savefig_to_stringio_with_distiller():
54-
if not matplotlib.checkdep_ghostscript():
55-
raise SkipTest("This test requires a GhostScript installation")
5664
matplotlib.rcParams['ps.usedistiller'] = 'ghostscript'
5765
_test_savefig_to_stringio()
5866

5967

6068
@cleanup
69+
@needs_tex
6170
def test_savefig_to_stringio_with_usetex():
62-
if not matplotlib.checkdep_tex():
63-
raise SkipTest("This test requires a TeX installation")
64-
6571
matplotlib.rcParams['text.latex.unicode'] = True
6672
matplotlib.rcParams['text.usetex'] = True
6773
_test_savefig_to_stringio()
@@ -73,10 +79,8 @@ def test_savefig_to_stringio_eps():
7379

7480

7581
@cleanup
82+
@needs_tex
7683
def test_savefig_to_stringio_with_usetex_eps():
77-
if not matplotlib.checkdep_tex():
78-
raise SkipTest("This test requires a TeX installation")
79-
8084
matplotlib.rcParams['text.latex.unicode'] = True
8185
matplotlib.rcParams['text.usetex'] = True
8286
_test_savefig_to_stringio(format='eps')

0 commit comments

Comments
 (0)
0