File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -131,13 +131,10 @@ def test_rasterized_ordering(fig_test, fig_ref):
131
131
132
132
def test_count_bitmaps ():
133
133
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 } " )
141
138
142
139
# No rasterized elements
143
140
fig1 = plt .figure ()
@@ -157,7 +154,7 @@ def count_tag(fig, tag):
157
154
assert count_tag (fig2 , "image" ) == 1
158
155
assert count_tag (fig2 , "path" ) == 1 # axis patch
159
156
160
- # rasterized can't be merged without effecting draw order
157
+ # rasterized can't be merged without affecting draw order
161
158
fig3 = plt .figure ()
162
159
ax3 = fig3 .add_subplot (1 , 1 , 1 )
163
160
ax3 .set_axis_off ()
You can’t perform that action at this time.
0 commit comments