Skip to content

Commit 4d11fe7

Browse files
miss-islingtonserhiy-storchaka
authored andcommitted
bpo-33760: Fix file leaks in test_io. (GH-7361) (GH-7370)
(cherry picked from commit e36837c) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 37343a2 commit 4d11fe7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Lib/test/test_io.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ def test_misbehaved_io_read(self):
15161516
def test_garbage_collection(self):
15171517
# C BufferedReader objects are collected.
15181518
# The Python version has __del__, so it ends into gc.garbage instead
1519+
self.addCleanup(support.unlink, support.TESTFN)
15191520
with support.check_warnings(('', ResourceWarning)):
15201521
rawio = self.FileIO(support.TESTFN, "w+b")
15211522
f = self.tp(rawio)
@@ -1718,6 +1719,7 @@ def test_destructor(self):
17181719

17191720
def test_truncate(self):
17201721
# Truncate implicitly flushes the buffer.
1722+
self.addCleanup(support.unlink, support.TESTFN)
17211723
with self.open(support.TESTFN, self.write_mode, buffering=0) as raw:
17221724
bufio = self.tp(raw, 8)
17231725
bufio.write(b"abcdef")
@@ -1730,6 +1732,7 @@ def test_truncate_after_write(self):
17301732
# Ensure that truncate preserves the file position after
17311733
# writes longer than the buffer size.
17321734
# Issue: https://bugs.python.org/issue32228
1735+
self.addCleanup(support.unlink, support.TESTFN)
17331736
with self.open(support.TESTFN, "wb") as f:
17341737
# Fill with some buffer
17351738
f.write(b'\x00' * 10000)
@@ -1851,6 +1854,7 @@ def test_garbage_collection(self):
18511854
# C BufferedWriter objects are collected, and collecting them flushes
18521855
# all data to disk.
18531856
# The Python version has __del__, so it ends into gc.garbage instead
1857+
self.addCleanup(support.unlink, support.TESTFN)
18541858
with support.check_warnings(('', ResourceWarning)):
18551859
rawio = self.FileIO(support.TESTFN, "w+b")
18561860
f = self.tp(rawio)

0 commit comments

Comments
 (0)