From: Serhiy Storchaka Date: Mon, 4 Jun 2018 03:37:57 +0000 (+0300) Subject: [2.7] bpo-33760: Fix file leaks in test_io. (GH-7361). (GH-7373) X-Git-Tag: v2.7.16rc1~277 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b02ceb57d23c26aca6666b3a9f4c5b7d84d0ea0a;p=thirdparty%2FPython%2Fcpython.git [2.7] bpo-33760: Fix file leaks in test_io. (GH-7361). (GH-7373) (cherry picked from commit e36837cb71032ccfa713e75623b314f091dc22bb) Co-authored-by: Serhiy Storchaka --- diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index ddb318a61c86..a7257115fc90 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1091,6 +1091,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) rawio = self.FileIO(support.TESTFN, "w+b") f = self.tp(rawio) f.f = f @@ -1292,6 +1293,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") @@ -1398,6 +1400,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) rawio = self.FileIO(support.TESTFN, "w+b") f = self.tp(rawio) f.write(b"123xxx")