Commit 5a9e91b0 authored by Brett Cannon's avatar Brett Cannon

Silence ResourceWarning when testing that the file destructor closes the file.

parent e1eca4e3
...@@ -461,13 +461,14 @@ class IOTest(unittest.TestCase): ...@@ -461,13 +461,14 @@ class IOTest(unittest.TestCase):
def flush(self): def flush(self):
record.append(3) record.append(3)
super().flush() super().flush()
f = MyFileIO(support.TESTFN, "wb") with support.check_warnings(('', ResourceWarning)):
f.write(b"xxx") f = MyFileIO(support.TESTFN, "wb")
del f f.write(b"xxx")
support.gc_collect() del f
self.assertEqual(record, [1, 2, 3]) support.gc_collect()
with self.open(support.TESTFN, "rb") as f: self.assertEqual(record, [1, 2, 3])
self.assertEqual(f.read(), b"xxx") with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"xxx")
def _check_base_destructor(self, base): def _check_base_destructor(self, base):
record = [] record = []
......
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