Skip to content

Commit 93c7214

Browse files
committed
Remove unnecessary file save during test.
1 parent 187e87b commit 93c7214

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/matplotlib/tests/test_backend_svg.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,10 @@ def test_rasterized_ordering(fig_test, fig_ref):
131131

132132
def 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()

0 commit comments

Comments
 (0)