[Python-checkins] bpo-33760: Fix file leaks in test_io. (GH-7361) (GH-7370)
Ned Deily
webhook-mailer at python.org
Sun Jun 3 23:15:14 EDT 2018
https://github.com/python/cpython/commit/4d11fe7cad9e138423e16338c88908f24a55f1cf
commit: 4d11fe7cad9e138423e16338c88908f24a55f1cf
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Ned Deily <nad at python.org>
date: 2018-06-03T23:15:10-04:00
summary:
bpo-33760: Fix file leaks in test_io. (GH-7361) (GH-7370)
(cherry picked from commit e36837cb71032ccfa713e75623b314f091dc22bb)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
M Lib/test/test_io.py
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 343c5a444072..286ae760e17f 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1516,6 +1516,7 @@ def test_misbehaved_io_read(self):
def test_garbage_collection(self):
# C BufferedReader objects are collected.
# The Python version has __del__, so it ends into gc.garbage instead
+ self.addCleanup(support.unlink, support.TESTFN)
with support.check_warnings(('', ResourceWarning)):
rawio = self.FileIO(support.TESTFN, "w+b")
f = self.tp(rawio)
@@ -1718,6 +1719,7 @@ def test_destructor(self):
def test_truncate(self):
# Truncate implicitly flushes the buffer.
+ self.addCleanup(support.unlink, support.TESTFN)
with self.open(support.TESTFN, self.write_mode, buffering=0) as raw:
bufio = self.tp(raw, 8)
bufio.write(b"abcdef")
@@ -1730,6 +1732,7 @@ def test_truncate_after_write(self):
# Ensure that truncate preserves the file position after
# writes longer than the buffer size.
# Issue: https://bugs.python.org/issue32228
+ self.addCleanup(support.unlink, support.TESTFN)
with self.open(support.TESTFN, "wb") as f:
# Fill with some buffer
f.write(b'\x00' * 10000)
@@ -1851,6 +1854,7 @@ def test_garbage_collection(self):
# C BufferedWriter objects are collected, and collecting them flushes
# all data to disk.
# The Python version has __del__, so it ends into gc.garbage instead
+ self.addCleanup(support.unlink, support.TESTFN)
with support.check_warnings(('', ResourceWarning)):
rawio = self.FileIO(support.TESTFN, "w+b")
f = self.tp(rawio)
More information about the Python-checkins
mailing list