Skip to content

Commit d18b13d

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

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
@@ -1496,6 +1496,7 @@ def test_misbehaved_io_read(self):
14961496
def test_garbage_collection(self):
14971497
# C BufferedReader objects are collected.
14981498
# The Python version has __del__, so it ends into gc.garbage instead
1499+
self.addCleanup(support.unlink, support.TESTFN)
14991500
with support.check_warnings(('', ResourceWarning)):
15001501
rawio = self.FileIO(support.TESTFN, "w+b")
15011502
f = self.tp(rawio)
@@ -1698,6 +1699,7 @@ def test_destructor(self):
16981699

16991700
def test_truncate(self):
17001701
# Truncate implicitly flushes the buffer.
1702+
self.addCleanup(support.unlink, support.TESTFN)
17011703
with self.open(support.TESTFN, self.write_mode, buffering=0) as raw:
17021704
bufio = self.tp(raw, 8)
17031705
bufio.write(b"abcdef")
@@ -1710,6 +1712,7 @@ def test_truncate_after_write(self):
17101712
# Ensure that truncate preserves the file position after
17111713
# writes longer than the buffer size.
17121714
# Issue: https://bugs.python.org/issue32228
1715+
self.addCleanup(support.unlink, support.TESTFN)
17131716
with self.open(support.TESTFN, "wb") as f:
17141717
# Fill with some buffer
17151718
f.write(b'\x00' * 10000)
@@ -1820,6 +1823,7 @@ def test_garbage_collection(self):
18201823
# C BufferedWriter objects are collected, and collecting them flushes
18211824
# all data to disk.
18221825
# The Python version has __del__, so it ends into gc.garbage instead
1826+
self.addCleanup(support.unlink, support.TESTFN)
18231827
with support.check_warnings(('', ResourceWarning)):
18241828
rawio = self.FileIO(support.TESTFN, "w+b")
18251829
f = self.tp(rawio)

0 commit comments

Comments
 (0)