8000 [3.8] bpo-37421: Fix test_shutil: don't leak temporary files (GH-14416) by miss-islington · Pull Request #14417 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.8] bpo-37421: Fix test_shutil: don't leak temporary files (GH-14416) #14417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-37421: Fix test_shutil: don't leak temporary files (GH-14416)
* Fix typo in supports_file2file_sendfile(); ensure that dst is
  removed
* Fix test_copytree_custom_copy_function(): remove dst tree.
  Use support.rmtree() rather than shutil.rmtree() to remove
  temporary directories: support tries harder.
(cherry picked from commit 4c26abd)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
  • Loading branch information
vstinner authored and miss-islington committed Jun 26, 2019
commit 2c914321e2d5f38f67da59107eec720cf2a1c648
5 changes: 3 additions & 2 deletions Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def supports_file2file_sendfile():

with open(srcname, "rb") as src:
with tempfile.NamedTemporaryFile("wb", delete=False) as dst:
dstname = f.name
dstname = dst.name
infd = src.fileno()
outfd = dst.fileno()
try:
Expand Down Expand Up @@ -878,8 +878,9 @@ def custom_cpfun(a, b):

flag = []
src = tempfile.mkdtemp()
self.addCleanup(support.rmtree, src)
dst = tempfile.mktemp()
self.addCleanup(shutil.rmtree, src)
self.addCle 8326 anup(support.rmtree, dst)
with open(os.path.join(src, 'foo'), 'w') as f:
f.close()
shutil.copytree(src, dst, copy_function=custom_cpfun)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix test_shutil to no longer leak temporary files.
0