Commit ebe5d8ae authored by Benjamin Peterson's avatar Benjamin Peterson

patch up leaking fds

parent d8fc2e1a
...@@ -555,6 +555,7 @@ class IOTest(unittest.TestCase): ...@@ -555,6 +555,7 @@ class IOTest(unittest.TestCase):
def test_garbage_collection(self): def test_garbage_collection(self):
# FileIO objects are collected, and collecting them flushes # FileIO objects are collected, and collecting them flushes
# all data to disk. # all data to disk.
with support.check_warnings(('', ResourceWarning)):
f = self.FileIO(support.TESTFN, "wb") f = self.FileIO(support.TESTFN, "wb")
f.write(b"abcxxx") f.write(b"abcxxx")
f.f = f f.f = f
...@@ -1984,10 +1985,9 @@ class TextIOWrapperTest(unittest.TestCase): ...@@ -1984,10 +1985,9 @@ class TextIOWrapperTest(unittest.TestCase):
u_suffix = "\u8888\n" u_suffix = "\u8888\n"
suffix = bytes(u_suffix.encode("utf-8")) suffix = bytes(u_suffix.encode("utf-8"))
line = prefix + suffix line = prefix + suffix
f = self.open(support.TESTFN, "wb") with self.open(support.TESTFN, "wb") as f:
f.write(line*2) f.write(line*2)
f.close() with self.open(support.TESTFN, "r", encoding="utf-8") as f:
f = self.open(support.TESTFN, "r", encoding="utf-8")
s = f.read(prefix_size) s = f.read(prefix_size)
self.assertEquals(s, str(prefix, "ascii")) self.assertEquals(s, str(prefix, "ascii"))
self.assertEquals(f.tell(), prefix_size) self.assertEquals(f.tell(), prefix_size)
...@@ -1996,10 +1996,9 @@ class TextIOWrapperTest(unittest.TestCase): ...@@ -1996,10 +1996,9 @@ class TextIOWrapperTest(unittest.TestCase):
def test_seeking_too(self): def test_seeking_too(self):
# Regression test for a specific bug # Regression test for a specific bug
data = b'\xe0\xbf\xbf\n' data = b'\xe0\xbf\xbf\n'
f = self.open(support.TESTFN, "wb") with self.open(support.TESTFN, "wb") as f:
f.write(data) f.write(data)
f.close() with self.open(support.TESTFN, "r", encoding="utf-8") as f:
f = self.open(support.TESTFN, "r", encoding="utf-8")
f._CHUNK_SIZE # Just test that it exists f._CHUNK_SIZE # Just test that it exists
f._CHUNK_SIZE = 2 f._CHUNK_SIZE = 2
f.readline() f.readline()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment