Skip to content

Commit 38f44d0

Browse files
committed
Tests: Add failing tests for LaTeX
1 parent b0a0a8e commit 38f44d0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/matplotlib/tests/test_backend_pdf.py

+12
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,15 @@ def test_pdf_savefig_when_color_is_none(tmpdir):
208208
fig.savefig(str(expected_image), format='eps')
209209
result = compare_images(str(actual_image), str(expected_image), 0)
210210
assert result is None
211+
212+
213+
def test_failing_latex(tmpdir):
214+
"""Test failing latex subprocess call"""
215+
path = tmpdir.join("tmpoutput.pdf")
216+
217+
rcParams['text.usetex'] = True
218+
219+
# This failes with "Double subscript"
220+
plt.xlabel("$%f_2_2$" % np.random.random())
221+
with pytest.raises(RuntimeError) as excinfo:
222+
plt.savefig(path)

lib/matplotlib/tests/test_backend_ps.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import matplotlib
1414
import matplotlib.pyplot as plt
15-
from matplotlib import patheffects
15+
from matplotlib import patheffects, rcParams
1616
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
1717
_determinism_check)
1818

@@ -174,3 +174,16 @@ def test_determinism_all():
174174
def test_determinism_all_tex():
175175
"""Test for reproducible PS/tex output"""
176176
_determinism_check(format="ps", usetex=True)
177+
178+
179+
@needs_tex
180+
def test_failing_latex(tmpdir):
181+
"""Test failing latex subprocess call"""
182+
path = tmpdir.join("tmpoutput.ps")
183+
184+
rcParams['text.usetex'] = True
185+
186+
# This failes with "Double subscript"
187+
plt.xlabel("$%f_2_2$" % np.random.random())
188+
with pytest.raises(RuntimeError) as excinfo:
189+
plt.savefig(path)

0 commit comments

Comments
 (0)