From: Brett Cannon Date: Fri, 29 Oct 2010 23:53:03 +0000 (+0000) Subject: Silence ResourceWarning when testing that the file destructor closes the file. X-Git-Tag: v3.2a4~271 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a9e91b050747ff6799f4cb4ed041bbacee8de07;p=python Silence ResourceWarning when testing that the file destructor closes the file. --- diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 7ce9753a38..d1973e5f3e 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -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 = []