From 2a1e3393862cbd52ee28d8c73f7b2d266a83b185 Mon Sep 17 00:00:00 2001 From: Thomas Spura Date: Mon, 17 Apr 2017 23:39:45 +0200 Subject: [PATCH] Tests: Add failing tests for LaTeX --- lib/matplotlib/tests/test_backend_pdf.py | 12 ++++++++++++ lib/matplotlib/tests/test_backend_ps.py | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py index 7f1439f89cf3..5440bc36a2d4 100644 --- a/lib/matplotlib/tests/test_backend_pdf.py +++ b/lib/matplotlib/tests/test_backend_pdf.py @@ -208,3 +208,15 @@ 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 + + +def test_failing_latex(tmpdir): + """Test failing latex subprocess call""" + path = tmpdir.join("tmpoutput.pdf") + + rcParams['text.usetex'] = True + + # This failes with "Double subscript" + plt.xlabel("$%f_2_2$" % np.random.random()) + with pytest.raises(RuntimeError) as excinfo: + plt.savefig(path) diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index f7bb1fb0e1be..0bc95e7b9d91 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -12,7 +12,7 @@ import matplotlib import matplotlib.pyplot as plt -from matplotlib import patheffects +from matplotlib import patheffects, rcParams from matplotlib.testing.determinism import (_determinism_source_date_epoch, _determinism_check) @@ -174,3 +174,16 @@ def test_determinism_all(): def test_determinism_all_tex(): """Test for reproducible PS/tex output""" _determinism_check(format="ps", usetex=True) + + +@needs_usetex +def test_failing_latex(tmpdir): + """Test failing latex subprocess call""" + path = tmpdir.join("tmpoutput.ps") + + rcParams['text.usetex'] = True + + # This failes with "Double subscript" + plt.xlabel("$%f_2_2$" % np.random.random()) + with pytest.raises(RuntimeError) as excinfo: + plt.savefig(path)