diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py index ded0af7f93c9..95ed12827ff5 100644 --- a/lib/matplotlib/tests/test_backend_pdf.py +++ b/lib/matplotlib/tests/test_backend_pdf.py @@ -218,3 +218,16 @@ def test_pdf_savefig_when_color_is_none(tmpdir): fig.savefig(str(expected_image), format='eps') result = compare_images(str(actual_image), str(expected_image), 0) assert result is None + + +@needs_usetex +def test_failing_latex(tmpdir): + """Test failing latex subprocess call""" + path = str(tmpdir.join("tmpoutput.pdf")) + + rcParams['text.usetex'] = True + + # This fails with "Double subscript" + plt.xlabel("$22_2_2$") + with pytest.raises(RuntimeError): + plt.savefig(path) diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index 0d86b32bd9b7..f93addeed014 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -157,3 +157,16 @@ def test_transparency(): ax.set_axis_off() ax.plot([0, 1], color="r", alpha=0) ax.text(.5, .5, "foo", color="r", alpha=0) + + +@needs_usetex +def test_failing_latex(tmpdir): + """Test failing latex subprocess call""" + path = str(tmpdir.join("tmpoutput.ps")) + + matplotlib.rcParams['text.usetex'] = True + + # This fails with "Double subscript" + plt.xlabel("$22_2_2$") + with pytest.raises(RuntimeError): + plt.savefig(path)