Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bddf528

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

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,11 @@ 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+
fd.seek(0)
137+
buf = fd.read().decode()
138+
return buf.count(f"<{tag}")
141139

142140
# No rasterized elements
143141
fig1 = plt.figure()
@@ -157,7 +155,7 @@ def count_tag(fig, tag):
157155
assert count_tag(fig2, "image") == 1
158156
assert count_tag(fig2, "path") == 1 # axis patch
159157

160-
# rasterized can't be merged without effecting draw order
158+
# rasterized can't be merged without affecting draw order
161159
fig3 = plt.figure()
162160
ax3 = fig3.add_subplot(1, 1, 1)
163161
ax3.set_axis_off()

0 commit comments

Comments
 (0)