summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-06-04 03:31:51 (GMT)
committerNed Deily <nad@python.org>2018-06-04 03:31:51 (GMT)
commitd18b13d36a22f93050a9d7cdfce594002f69236f (patch)
tree18f7b7c092b29f23da763088ff8b002c4fe409a6 /Lib/test/test_io.py
parent7f1bcda9bc3c04100cb047373732db0eba00e581 (diff)
downloadcpython-d18b13d36a22f93050a9d7cdfce594002f69236f.zip
cpython-d18b13d36a22f93050a9d7cdfce594002f69236f.tar.gz
cpython-d18b13d36a22f93050a9d7cdfce594002f69236f.tar.bz2
bpo-33760: Fix file leaks in test_io. (GH-7361) (GH-7372)
(cherry picked from commit e36837cb71032ccfa713e75623b314f091dc22bb) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 22f79d7..0b5b033 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1496,6 +1496,7 @@ class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
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)
@@ -1698,6 +1699,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
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")
@@ -1710,6 +1712,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
# 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)
@@ -1820,6 +1823,7 @@ class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
# 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)