Skip to content

Commit

Permalink
BUG: fix test error when ghostscript not installed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthew-brett committed Jul 26, 2014
1 parent e76996f commit bd852df
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@
import re

import six
from nose.plugins.skip import SkipTest

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.testing.decorators import cleanup
from matplotlib.testing.decorators import cleanup, knownfailureif


needs_ghostscript = knownfailureif(
matplotlib.checkdep_ghostscript()[0] is None,
"This test needs a ghostscript installation")


needs_tex = knownfailureif(
not matplotlib.checkdep_tex(),
"This test needs a TeX installation")


def _test_savefig_to_stringio(format='ps'):
Expand Down Expand Up @@ -50,18 +59,15 @@ def test_savefig_to_stringio():


@cleanup
@needs_ghostscript
def test_savefig_to_stringio_with_distiller():
if not matplotlib.checkdep_ghostscript():
raise SkipTest("This test requires a GhostScript installation")
matplotlib.rcParams['ps.usedistiller'] = 'ghostscript'
_test_savefig_to_stringio()


@cleanup
@needs_tex
def test_savefig_to_stringio_with_usetex():
if not matplotlib.checkdep_tex():
raise SkipTest("This test requires a TeX installation")

matplotlib.rcParams['text.latex.unicode'] = True
matplotlib.rcParams['text.usetex'] = True
_test_savefig_to_stringio()
Expand All @@ -73,10 +79,8 @@ def test_savefig_to_stringio_eps():


@cleanup
@needs_tex
def test_savefig_to_stringio_with_usetex_eps():
if not matplotlib.checkdep_tex():
raise SkipTest("This test requires a TeX installation")

matplotlib.rcParams['text.latex.unicode'] = True
matplotlib.rcParams['text.usetex'] = True
_test_savefig_to_stringio(format='eps')
Expand Down

0 comments on commit bd852df

Please sign in to comment.