Skip to content

Add tests for the external process calls #8504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 14 additions & 1 deletion lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)