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

This commit is contained in:
Brett Cannon 2010-10-29 23:53:03 +00:00
parent e1eca4e3f5
commit 5a9e91b050
1 changed files with 8 additions and 7 deletions

View File

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