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

Skip to content

Commit 386a088

Browse files
committed
TST: do not remove files while they are open
Fixes WindowsError: [Error 32] The process cannot access the file because it is being used by another process
1 parent 047c60a commit 386a088

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_multipage_keep_empty():
6464
with PdfPages(tmp) as pdf:
6565
filename = pdf._file.fh.name
6666
assert os.path.exists(filename)
67-
os.remove(filename)
67+
os.remove(filename)
6868
# test if an empty pdf is deleting itself afterwards with keep_empty=False
6969
with NamedTemporaryFile(delete=False) as tmp:
7070
with PdfPages(tmp, keep_empty=False) as pdf:
@@ -80,11 +80,11 @@ def test_multipage_keep_empty():
8080
filename = pdf._file.fh.name
8181
pdf.savefig()
8282
assert os.path.exists(filename)
83-
os.remove(filename)
83+
os.remove(filename)
8484
# test that a non-empty pdf is left behind with keep_empty=False
8585
with NamedTemporaryFile(delete=False) as tmp:
8686
with PdfPages(tmp, keep_empty=False) as pdf:
8787
filename = pdf._file.fh.name
8888
pdf.savefig()
8989
assert os.path.exists(filename)
90-
os.remove(filename)
90+
os.remove(filename)

0 commit comments

Comments
 (0)