@@ -303,24 +303,17 @@ def test_get_unicode_index_exception():
303303
304304
305305def test_single_minus_sign ():
306- plt .figure (figsize = (0.3 , 0.3 ))
307- plt .text (0.5 , 0.5 , '$-$' )
308- plt .gca ().spines [:].set_visible (False )
309- plt .gca ().set_xticks ([])
310- plt .gca ().set_yticks ([])
311-
312- buff = io .BytesIO ()
313- plt .savefig (buff , format = "rgba" , dpi = 1000 )
314- array = np .frombuffer (buff .getvalue (), dtype = np .uint8 )
315-
316- # If this fails, it would be all white
317- assert not np .all (array == 0xff )
306+ fig = plt .figure ()
307+ fig .text (0.5 , 0.5 , '$-$' )
308+ fig .canvas .draw ()
309+ t = np .asarray (fig .canvas .renderer .buffer_rgba ())
310+ assert (t != 0xff ).any () # assert that canvas is not all white.
318311
319312
320313@check_figures_equal (extensions = ["png" ])
321314def test_spaces (fig_test , fig_ref ):
322- fig_test .subplots (). set_title ( r"$1\,2\>3\ 4$" )
323- fig_ref .subplots (). set_title ( r"$1\/2\:3~4$" )
315+ fig_test .text ( .5 , .5 , r"$1\,2\>3\ 4$" )
316+ fig_ref .text ( .5 , .5 , r"$1\/2\:3~4$" )
324317
325318
326319@check_figures_equal (extensions = ["png" ])
0 commit comments