From 93c721423088f25c0e8c4cbb6a1811610003658c Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 14 Jul 2020 21:33:45 -0400 Subject: [PATCH] Remove unnecessary file save during test. --- lib/matplotlib/tests/test_backend_svg.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/tests/test_backend_svg.py b/lib/matplotlib/tests/test_backend_svg.py index 972e8389f68e..cc68c1ccf577 100644 --- a/lib/matplotlib/tests/test_backend_svg.py +++ b/lib/matplotlib/tests/test_backend_svg.py @@ -131,13 +131,10 @@ def test_rasterized_ordering(fig_test, fig_ref): def test_count_bitmaps(): def count_tag(fig, tag): - fd = BytesIO() - fig.savefig(fd, format='svg') - fd.seek(0) - buf = fd.read().decode() - fd.close() - open("test.svg", "w").write(buf) - return buf.count("<%s" % tag) + with BytesIO() as fd: + fig.savefig(fd, format='svg') + buf = fd.getvalue().decode() + return buf.count(f"<{tag}") # No rasterized elements fig1 = plt.figure() @@ -157,7 +154,7 @@ def count_tag(fig, tag): assert count_tag(fig2, "image") == 1 assert count_tag(fig2, "path") == 1 # axis patch - # rasterized can't be merged without effecting draw order + # rasterized can't be merged without affecting draw order fig3 = plt.figure() ax3 = fig3.add_subplot(1, 1, 1) ax3.set_axis_off()