Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9721cb7

Browse files
tomspurQuLogic
authored andcommitted
Tests: Add failing tests for LaTeX
1 parent 32a67d3 commit 9721cb7

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,15 @@ def test_pdf_savefig_when_color_is_none(tmpdir):
218218
fig.savefig(str(expected_image), format='eps')
219219
result = compare_images(str(actual_image), str(expected_image), 0)
220220
assert result is None
221+
222+
223+
def test_failing_latex(tmpdir):
224+
"""Test failing latex subprocess call"""
225+
path = tmpdir.join("tmpoutput.pdf")
226+
227+
rcParams['text.usetex'] = True
228+
229+
# This failes with "Double subscript"
230+
plt.xlabel("$%f_2_2$" % np.random.random())
231+
with pytest.raises(RuntimeError) as excinfo:
232+
plt.savefig(path)

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import matplotlib
1313
import matplotlib.pyplot as plt
14-
from matplotlib import patheffects
14+
from matplotlib import patheffects, rcParams
1515
from matplotlib.testing.decorators import image_comparison
1616
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
1717
_determinism_check)
@@ -157,3 +157,16 @@ def test_transparency():
157157
ax.set_axis_off()
158158
ax.plot([0, 1], color="r", alpha=0)
159159
ax.text(.5, .5, "foo", color="r", alpha=0)
160+
161+
162+
@needs_usetex
163+
def test_failing_latex(tmpdir):
164+
"""Test failing latex subprocess call"""
165+
path = tmpdir.join("tmpoutput.ps")
166+
167+
rcParams['text.usetex'] = True
168+
169+
# This failes with "Double subscript"
170+
plt.xlabel("$%f_2_2$" % np.random.random())
171+
with pytest.raises(RuntimeError) as excinfo:
172+
plt.savefig(path)

0 commit comments

Comments
 (0)