File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 12
12
import pytest
13
13
14
14
import numpy as np
15
+ import matplotlib
15
16
from matplotlib import checkdep_tex , cm , rcParams
16
17
from matplotlib .backends .backend_pdf import PdfPages
17
18
from matplotlib import pyplot as plt
@@ -191,3 +192,20 @@ def psfont(*args, **kwargs):
191
192
ax .text (0.5 , 0.5 , 'hello' )
192
193
with tempfile .TemporaryFile () as tmpfile , pytest .raises (ValueError ):
193
194
fig .savefig (tmpfile , format = 'pdf' )
195
+
196
+
197
+ @needs_tex
198
+ def test_failing_latex (tmpdir ):
199
+ """Test failing latex subprocess call"""
200
+ path = tmpdir .join ("tmpoutput.pdf" )
201
+
202
+ matplotlib .rcParams ['text.usetex' ] = True
203
+
204
+ # This failes with "Double subscript"
205
+ plt .xlabel ("$%f_2_2$" % np .random .random ())
206
+ with pytest .raises (RuntimeError ) as excinfo :
207
+ plt .savefig (path )
208
+ output = str (excinfo .value )
209
+ assert "LaTeX was not able to process the following string:" \
210
+ in output
211
+ assert "Double subscript." in output
Original file line number Diff line number Diff line change @@ -188,3 +188,20 @@ def test_determinism_all():
188
188
def test_determinism_all_tex ():
189
189
"""Test for reproducible PS/tex output"""
190
190
_determinism_check (format = "ps" , usetex = True )
191
+
192
+
193
+ @needs_tex
194
+ def test_failing_latex (tmpdir ):
195
+ """Test failing latex subprocess call"""
196
+ path = tmpdir .join ("tmpoutput.ps" )
197
+
198
+ matplotlib .rcParams ['text.usetex' ] = True
199
+
200
+ # This failes with "Double subscript"
201
+ plt .xlabel ("$%f_2_2$" % np .random .random ())
202
+ with pytest .raises (RuntimeError ) as excinfo :
203
+ plt .savefig (path )
204
+ output = str (excinfo .value )
205
+ assert "LaTeX was not able to process the following string:" \
206
+ in output
207
+ assert "Double subscript." in output
You can’t perform that action at this time.
0 commit comments