diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 491623e7d03a..4e3f4a23f859 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -641,6 +641,28 @@ def test_sticky_shared_axes(fig_test, fig_ref): ax0.pcolormesh(Z) +def test_nargs_stem(): + with pytest.raises(TypeError, match='0 were given'): + # stem() takes 1-3 arguments. + plt.stem() + + +def test_nargs_legend(): + with pytest.raises(TypeError, match='3 were given'): + ax = plt.subplot() + # legend() takes 0-2 arguments. + ax.legend(['First'], ['Second'], 3) + + +def test_nargs_pcolorfast(): + with pytest.raises(TypeError, match='2 were given'): + ax = plt.subplot() + # pcolorfast() takes 1 or 3 arguments, + # not passing any arguments fails at C = args[-1] + # before nargs_err is raised. + ax.pcolorfast([(0, 1), (0, 2)], [[1, 2, 3], [1, 2, 3]]) + + @image_comparison(['offset_points'], remove_text=True) def test_basic_annotate(): # Setup some data diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index bdaf5b593a5f..ce20f57ef665 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -118,6 +118,13 @@ def test_rcparams_init(): mpl.RcParams({'figure.figsize': (3.5, 42, 1)}) +def test_nargs_cycler(): + from matplotlib.rcsetup import cycler as ccl + with pytest.raises(TypeError, match='3 were given'): + # cycler() takes 0-2 arguments. + ccl(ccl(color=list('rgb')), 2, 3) + + def test_Bug_2543(): # Test that it possible to add all values to itself / deepcopy # https://github.com/matplotlib/matplotlib/issues/2543