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

Skip to content

Commit f051d94

Browse files
authored
Merge pull request #25891 from turnipseason/add-tests-for-nargs-err
Adds tests for nargs_err in legend, stem, pcolorfast and cycler.
2 parents 0134e6d + b554c8c commit f051d94

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,28 @@ def test_sticky_shared_axes(fig_test, fig_ref):
662662
ax0.pcolormesh(Z)
663663

664664

665+
def test_nargs_stem():
666+
with pytest.raises(TypeError, match='0 were given'):
667+
# stem() takes 1-3 arguments.
668+
plt.stem()
669+
670+
671+
def test_nargs_legend():
672+
with pytest.raises(TypeError, match='3 were given'):
673+
ax = plt.subplot()
674+
# legend() takes 0-2 arguments.
675+
ax.legend(['First'], ['Second'], 3)
676+
677+
678+
def test_nargs_pcolorfast():
679+
with pytest.raises(TypeError, match='2 were given'):
680+
ax = plt.subplot()
681+
# pcolorfast() takes 1 or 3 arguments,
682+
# not passing any arguments fails at C = args[-1]
683+
# before nargs_err is raised.
684+
ax.pcolorfast([(0, 1), (0, 2)], [[1, 2, 3], [1, 2, 3]])
685+
686+
665687
@image_comparison(['offset_points'], remove_text=True)
666688
def test_basic_annotate():
667689
# Setup some data

lib/matplotlib/tests/test_rcparams.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ def test_rcparams_init():
118118
mpl.RcParams({'figure.figsize': (3.5, 42, 1)})
119119

120120

121+
def test_nargs_cycler():
122+
from matplotlib.rcsetup import cycler as ccl
123+
with pytest.raises(TypeError, match='3 were given'):
124+
# cycler() takes 0-2 arguments.
125+
ccl(ccl(color=list('rgb')), 2, 3)
126+
127+
121128
def test_Bug_2543():
122129
# Test that it possible to add all values to itself / deepcopy
123130
# https://github.com/matplotlib/matplotlib/issues/2543

0 commit comments

Comments
 (0)