@@ -390,17 +390,14 @@ def test_legend_kwargs_handles_labels(self):
390
390
ax .legend (labels = ('a' , 'b' ), handles = (lnc , lns ))
391
391
Legend .assert_called_with (ax , (lnc , lns ), ('a' , 'b' ))
392
392
393
- def test_warn_mixed_args_and_kwargs (self ):
393
+ def test_error_mixed_args_and_kwargs (self ):
394
394
fig , ax = plt .subplots ()
395
395
th = np .linspace (0 , 2 * np .pi , 1024 )
396
396
lns , = ax .plot (th , np .sin (th ), label = 'sin' )
397
397
lnc , = ax .plot (th , np .cos (th ), label = 'cos' )
398
- with pytest .warns (DeprecationWarning ) as record :
398
+ msg = 'must both be passed positionally or both as keywords'
399
+ with pytest .raises (TypeError , match = msg ):
399
400
ax .legend ((lnc , lns ), labels = ('a' , 'b' ))
400
- assert len (record ) == 1
401
- assert str (record [0 ].message ).startswith (
402
- "You have mixed positional and keyword arguments, some input may "
403
- "be discarded." )
404
401
405
402
def test_parasite (self ):
406
403
from mpl_toolkits .axes_grid1 import host_subplot # type: ignore[import]
@@ -460,16 +457,13 @@ def test_legend_kw_args(self):
460
457
fig , (lines , lines2 ), ('a' , 'b' ), loc = 'right' ,
461
458
bbox_transform = fig .transFigure )
462
459
463
- def test_warn_args_kwargs (self ):
460
+ def test_error_args_kwargs (self ):
464
461
fig , axs = plt .subplots (1 , 2 )
465
462
lines = axs [0 ].plot (range (10 ))
466
463
lines2 = axs [1 ].plot (np .arange (10 ) * 2. )
467
- with pytest .warns (DeprecationWarning ) as record :
464
+ msg = 'must both be passed positionally or both as keywords'
465
+ with pytest .raises (TypeError , match = msg ):
468
466
fig .legend ((lines , lines2 ), labels = ('a' , 'b' ))
469
- assert len (record ) == 1
470
- assert str (record [0 ].message ).startswith (
471
- "You have mixed positional and keyword arguments, some input may "
472
- "be discarded." )
473
467
474
468
475
469
def test_figure_legend_outside ():
@@ -1178,21 +1172,15 @@ def test_plot_multiple_input_single_label(label):
1178
1172
assert legend_texts == [str (label )] * 2
1179
1173
1180
1174
1181
- @pytest .mark .parametrize ('label_array' , [['low' , 'high' ],
1182
- ('low' , 'high' ),
1183
- np .array (['low' , 'high' ])])
1184
- def test_plot_single_input_multiple_label (label_array ):
1175
+ def test_plot_single_input_multiple_label ():
1185
1176
# test ax.plot() with 1D array like input
1186
1177
# and iterable label
1187
1178
x = [1 , 2 , 3 ]
1188
1179
y = [2 , 5 , 6 ]
1189
1180
fig , ax = plt .subplots ()
1190
- with pytest .warns (mpl .MatplotlibDeprecationWarning ,
1191
- match = 'Passing label as a length 2 sequence' ):
1192
- ax .plot (x , y , label = label_array )
1193
- leg = ax .legend ()
1194
- assert len (leg .get_texts ()) == 1
1195
- assert leg .get_texts ()[0 ].get_text () == str (label_array )
1181
+ with pytest .raises (ValueError ,
1182
+ match = 'label must be scalar or have the same length' ):
1183
+ ax .plot (x , y , label = ['low' , 'high' ])
1196
1184
1197
1185
1198
1186
def test_plot_single_input_list_label ():
0 commit comments