File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,13 +131,10 @@ def test_rasterized_ordering(fig_test, fig_ref):
131131
132132def test_count_bitmaps ():
133133 def count_tag (fig , tag ):
134- fd = BytesIO ()
135- fig .savefig (fd , format = 'svg' )
136- fd .seek (0 )
137- buf = fd .read ().decode ()
138- fd .close ()
139- open ("test.svg" , "w" ).write (buf )
140- return buf .count ("<%s" % tag )
134+ with BytesIO () as fd :
135+ fig .savefig (fd , format = 'svg' )
136+ buf = fd .getvalue ().decode ()
137+ return buf .count (f"<{ tag } " )
141138
142139 # No rasterized elements
143140 fig1 = plt .figure ()
@@ -157,7 +154,7 @@ def count_tag(fig, tag):
157154 assert count_tag (fig2 , "image" ) == 1
158155 assert count_tag (fig2 , "path" ) == 1 # axis patch
159156
160- # rasterized can't be merged without effecting draw order
157+ # rasterized can't be merged without affecting draw order
161158 fig3 = plt .figure ()
162159 ax3 = fig3 .add_subplot (1 , 1 , 1 )
163160 ax3 .set_axis_off ()
You can’t perform that action at this time.
0 commit comments