@@ -282,12 +282,12 @@ def test_warn_args_kwargs(self):
282
282
th = np .linspace (0 , 2 * np .pi , 1024 )
283
283
lns , = ax .plot (th , np .sin (th ), label = 'sin' , lw = 5 )
284
284
lnc , = ax .plot (th , np .cos (th ), label = 'cos' , lw = 5 )
285
- with mock . patch ( 'warnings.warn' ) as warn :
285
+ with pytest . warns ( UserWarning ) as record :
286
286
ax .legend ((lnc , lns ), labels = ('a' , 'b' ))
287
-
288
- warn . assert_called_with ( "You have mixed positional and keyword "
289
- " arguments, some input may be "
290
- " discarded." )
287
+ assert len ( record ) == 1
288
+ assert str ( record [ 0 ]. message ) == (
289
+ "You have mixed positional and keyword arguments, some input may "
290
+ "be discarded." )
291
291
292
292
def test_parasite (self ):
293
293
from mpl_toolkits .axes_grid1 import host_subplot
@@ -356,11 +356,12 @@ def test_warn_args_kwargs(self):
356
356
fig , axs = plt .subplots (1 , 2 )
357
357
lines = axs [0 ].plot (range (10 ))
358
358
lines2 = axs [1 ].plot (np .arange (10 ) * 2. )
359
- with mock . patch ( 'warnings.warn' ) as warn :
359
+ with pytest . warns ( UserWarning ) as record :
360
360
fig .legend ((lines , lines2 ), labels = ('a' , 'b' ))
361
- warn .assert_called_with ("You have mixed positional and keyword "
362
- "arguments, some input may be "
363
- "discarded." )
361
+ assert len (record ) == 1
362
+ assert str (record [0 ].message ) == (
363
+ "You have mixed positional and keyword arguments, some input may "
364
+ "be discarded." )
364
365
365
366
366
367
@image_comparison (baseline_images = ['legend_stackplot' ], extensions = ['png' ])
0 commit comments