8000 Changed assertions to pytest.raises matches. · matplotlib/matplotlib@56d62c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 56d62c6

Browse files
committed
Changed assertions to pytest.raises matches.
1 parent 331af2c commit 56d62c6

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,28 +642,25 @@ def test_sticky_shared_axes(fig_test, fig_ref):
642642

643643

644644
def test_nargs_stem():
645-
with pytest.raises(TypeError) as e:
645+
with pytest.raises(TypeError, match='0 were given') as e:
646646
# stem() takes 1-3 arguments.
647647
plt.stem()
648-
assert "stem() takes 1-3" in str(e.value)
649648

650649

651650
def test_nargs_legend():
652-
with pytest.raises(TypeError) as e:
651+
with pytest.raises(TypeError, match='3 were given') as e:
653652
ax = plt.subplot()
654653
# legend() takes 0-2 arguments.
655654
ax.legend(['First'], ['Second'], 3)
656-
assert "legend() takes 0-2" in str(e.value)
657655

658656

659657
def test_nargs_pcolorfast():
660-
with pytest.raises(TypeError) as e:
658+
with pytest.raises(TypeError, match='2 were given') as e:
661659
ax = plt.subplot()
662660
# pcolorfast() takes 1 or 3 arguments,
663661
# not passing any arguments fails at C = args[-1]
664662
# before nargs_err is raised.
665663
ax.pcolorfast([(0, 1), (0, 2)], [[1, 2, 3], [1, 2, 3]])
666-
assert "pcolorfast() takes 1 or 3" in str(e.value)
667664

668665

669666
@image_comparison(['offset_points'], remove_text=True)

lib/matplotlib/tests/test_rcparams.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ def test_rcparams_init():
120120

121121
def test_nargs_cycler():
122122
from matplotlib.rcsetup import cycler as ccl
123-
with pytest.raises(TypeError) as e:
123+
with pytest.raises(TypeError, match='3 were given') as e:
124124
# cycler() takes 0-2 arguments.
125125
ccl(ccl(color=list('rgb')), 2, 3)
126-
assert "cycler() takes 0-2" in str(e.value)
127126

128127

129128
def test_Bug_2543():

0 commit comments

Comments
 (0)
0