Skip to content

Commit 58d2e23

Browse files
committed
Tests: Add failing tests for LaTeX
1 parent 4d9738f commit 58d2e23

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/matplotlib/tests/test_backend_pdf.py

+18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313

1414
import numpy as np
15+
import matplotlib
1516
from matplotlib import checkdep_tex, cm, rcParams
1617
from matplotlib.backends.backend_pdf import PdfPages
1718
from matplotlib import pyplot as plt
@@ -191,3 +192,20 @@ def psfont(*args, **kwargs):
191192
ax.text(0.5, 0.5, 'hello')
192193
with tempfile.TemporaryFile() as tmpfile, pytest.raises(ValueError):
193194
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

lib/matplotlib/tests/test_backend_ps.py

+17
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,20 @@ def test_determinism_all():
188188
def test_determinism_all_tex():
189189
"""Test for reproducible PS/tex output"""
190190
_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

0 commit comments

Comments
 (0)