From 2679dddf8089edb9f6d42bf7e72ada4ae601e64f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 22 Dec 2016 18:06:12 -0500 Subject: [PATCH] Save SVG test directly to file instead of its name. Windows doesn't like opening files twice, so this needs to save to the file name _outside_ the context (after it's been closed), or simply write to the file object directly. There doesn't seem to be any pressing need to use the file name, so just use the file object. --- lib/matplotlib/tests/test_backend_svg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_backend_svg.py b/lib/matplotlib/tests/test_backend_svg.py index 6200aa53dd78..ba2d24cda56b 100644 --- a/lib/matplotlib/tests/test_backend_svg.py +++ b/lib/matplotlib/tests/test_backend_svg.py @@ -217,8 +217,8 @@ def test_missing_psfont(mock): rc('text', usetex=True) fig, ax = plt.subplots() ax.text(0.5, 0.5, 'hello') - with tempfile.NamedTemporaryFile(suffix='.svg') as tmpfile: - fig.savefig(tmpfile.name) + with tempfile.TemporaryFile() as tmpfile: + fig.savefig(tmpfile, format='svg') if __name__ == '__main__':