8000 TST: some tex tests also need to guard against missing gs · matplotlib/matplotlib@890c5ad · GitHub
[go: up one dir, main page]

Skip to content

Commit 890c5ad

Browse files
jankatinsmatthew-brett
authored andcommitted
TST: some tex tests also need to guard against missing gs
Also fixed a problem in an error message when bytes were appended to a string (fails on py3.x) by using %. One of the errors before: ====================================================================== ERROR: matplotlib.tests.test_backend_ps.test_savefig_to_stringio_with_usetex ---------------------------------------------------------------------- Traceback (most recent call last): File "lib\site-packages\nose\case.py", line 198, in runTest self.test(*self.arg) File "lib\matplotlib\testing\decorators.py", line 152, in wrapped_callable func(*args, **kwargs) File "lib\matplotlib\testing\decorators.py", line 55, in failer result = f(*args, **kwargs) File "lib\matplotlib\tests\test_backend_ps.py", line 77, in test_savefig_to_stringio_with_usetex _test_savefig_to_stringio() File "lib\matplotlib\tests\test_backend_ps.py", line 40, in _test_savefig_to_stringio fig.savefig(buffer, format=format) File "lib\matplotlib\figure.py", line 1698, in savefig self.canvas.print_figure(*args, **kwargs) File "lib\matplotlib\backend_bases.py", line 2232, in print_figure **kwargs) File "lib\matplotlib\backends\backend_ps.py", line 985, in print_ps return self._print_ps(outfile, 'ps', *args, **kwargs) File "lib\matplotlib\backends\backend_ps.py", line 1012, in _print_ps **kwargs) File "lib\matplotlib\backends\backend_ps.py", line 1376, in _print_figure_tex rotated=psfrag_rotated) File "lib\matplotlib\backends\backend_ps.py", line 1539, in gs_distill raise RuntimeError(m % output) RuntimeError: ghostscript was not able to process your image. Here is the full report generated by ghostscript: b''
1 parent a32d8ac commit 890c5ad

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,13 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
15031503

15041504
with io.open(outfile, 'rb') as fh:
15051505
if exit_status:
1506-
raise RuntimeError('ghostscript was not able to process \
1507-
your image.\nHere is the full report generated by ghostscript:\n\n' + fh.read())
1506+
output = fh.read()
1507+
m = "\n".join(["ghostscript was not able to process your image.",
1508+
"Here is the full report generated by ghostscript:",
1509+
"",
1510+
"%s"])
1511+
# use % to prevent problems with bytes
1512+
raise RuntimeError(m % output)
15081513
else:
15091514
verbose.report(fh.read(), 'debug')
15101515
os.remove(outfile)

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_savefig_to_stringio_with_distiller():
7171

7272
@cleanup
7373
@needs_tex
74+
@needs_ghostscript
7475
def test_savefig_to_stringio_with_usetex():
7576
matplotlib.rcParams['text.latex.unicode'] = True
7677
matplotlib.rcParams['text.usetex'] = True
@@ -90,6 +91,7 @@ def test_savefig_to_stringio_eps_afm():
9091

9192
@cleanup
9293
@needs_tex
94+
@needs_ghostscript
9395
def test_savefig_to_stringio_with_usetex_eps():
9496
matplotlib.rcParams['text.latex.unicode'] = True
9597
matplotlib.rcParams['text.usetex'] = True

0 commit comments

Comments
 (0)
0