8000 Adds tests for nargs_err in legend, stem, pcolorfast and cycler. · matplotlib/matplotlib@331af2c · GitHub
[go: up one dir, main page]

Skip to content

Commit 331af2c

Browse files
committed
Adds tests for nargs_err in legend, stem, pcolorfast and cycler.
1 parent 81661df commit 331af2c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,31 @@ def test_sticky_shared_axes(fig_test, fig_ref):
641641
ax0.pcolormesh(Z)
642642

643643

644+
def test_nargs_stem():
645+
with pytest.raises(TypeError) as e:
646+
# stem() takes 1-3 arguments.
647+
plt.stem()
648+
assert "stem() takes 1-3" in str(e.value)
649+
650+
651+
def test_nargs_legend():
652+
with pytest.raises(TypeError) as e:
653+
ax = plt.subplot()
654+
# legend() takes 0-2 arguments.
655+
ax.legend(['First'], ['Second'], 3)
656+
assert "legend() takes 0-2" in str(e.value)
657+
658+
659+
def test_nargs_pcolorfast():
660+
with pytest.raises(TypeError) as e:
661+
ax = plt.subplot()
662+
# pcolorfast() takes 1 or 3 arguments,
663+
# not passing any arguments fails at C = args[-1]
664+
# before nargs_err is raised.
665+
ax.pcolorfast([(0, 1), (0, 2)], [[1, 2, 3], [1, 2, 3]])
666+
assert "pcolorfast() takes 1 or 3" in str(e.value)
667+
668+
644669
@image_comparison(['offset_points'], remove_text=True)
645670
def test_basic_annotate():
646671
# Setup some data

lib/matplotlib/tests/test_rcparams.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ 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) as e:
124+
# cycler() takes 0-2 arguments.
125+
ccl(ccl(color=list('rgb')), 2, 3)
126+
assert "cycler() takes 0-2" in str(e.value)
127+
128+
121129
def test_Bug_2543():
122130
# Test that it possible to add all values to itself / deepcopy
123131
# https://github.com/matplotlib/matplotlib/issues/2543

0 commit comments

Comments
 (0)
0