@@ -282,12 +282,12 @@ def test_warn_args_kwargs(self):
282282 th = np .linspace (0 , 2 * np .pi , 1024 )
283283 lns , = ax .plot (th , np .sin (th ), label = 'sin' , lw = 5 )
284284 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 :
286286 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." )
291291
292292 def test_parasite (self ):
293293 from mpl_toolkits .axes_grid1 import host_subplot
@@ -356,11 +356,12 @@ def test_warn_args_kwargs(self):
356356 fig , axs = plt .subplots (1 , 2 )
357357 lines = axs [0 ].plot (range (10 ))
358358 lines2 = axs [1 ].plot (np .arange (10 ) * 2. )
359- with mock . patch ( 'warnings.warn' ) as warn :
359+ with pytest . warns ( UserWarning ) as record :
360360 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." )
364365
365366
366367@image_comparison (baseline_images = ['legend_stackplot' ], extensions = ['png' ])
0 commit comments