Skip to content

Commit 7cf0e22

Browse files
committed
TST: Cleanup new tests a bit.
Matplotlib doesn't support pytest Path objects, so convert to str. Remove unnecessary randomness and fix typos.
1 parent 9721cb7 commit 7cf0e22

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/matplotlib/tests/test_backend_pdf.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,14 @@ def test_pdf_savefig_when_color_is_none(tmpdir):
220220
assert result is None
221221

222222

223+
@needs_usetex
223224
def test_failing_latex(tmpdir):
224225
"""Test failing latex subprocess call"""
225-
path = tmpdir.join("tmpoutput.pdf")
226+
path = str(tmpdir.join("tmpoutput.pdf"))
226227

227228
rcParams['text.usetex'] = True
228229

229-
# This failes with "Double subscript"
230-
plt.xlabel("$%f_2_2$" % np.random.random())
231-
with pytest.raises(RuntimeError) as excinfo:
230+
# This fails with "Double subscript"
231+
plt.xlabel("$22_2_2$")
232+
with pytest.raises(RuntimeError):
232233
plt.savefig(path)

lib/matplotlib/tests/test_backend_ps.py

+6-6
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, rcParams
14+
from matplotlib import patheffects
1515
from matplotlib.testing.decorators import image_comparison
1616
from matplotlib.testing.determinism import (_determinism_source_date_epoch,
1717
_determinism_check)
@@ -162,11 +162,11 @@ def test_transparency():
162162
@needs_usetex
163163
def test_failing_latex(tmpdir):
164164
"""Test failing latex subprocess call"""
165-
path = tmpdir.join("tmpoutput.ps")
165+
path = str(tmpdir.join("tmpoutput.ps"))
166166

167-
rcParams['text.usetex'] = True
167+
matplotlib.rcParams['text.usetex'] = True
168168

169-
# This failes with "Double subscript"
170-
plt.xlabel("$%f_2_2$" % np.random.random())
171-
with pytest.raises(RuntimeError) as excinfo:
169+
# This fails with "Double subscript"
170+
plt.xlabel("$22_2_2$")
171+
with pytest.raises(RuntimeError):
172172
plt.savefig(path)

0 commit comments

Comments
 (0)