summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-10-29 23:53:03 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-10-29 23:53:03 (GMT)
commit5a9e91b050747ff6799f4cb4ed041bbacee8de07 (patch)
tree1ab18a041f2006505764a2d886ca186a8573a240 /Lib/test/test_io.py
parente1eca4e3f58bc221cea828a58a27088bc9258157 (diff)
downloadcpython-5a9e91b050747ff6799f4cb4ed041bbacee8de07.zip
cpython-5a9e91b050747ff6799f4cb4ed041bbacee8de07.tar.gz
cpython-5a9e91b050747ff6799f4cb4ed041bbacee8de07.tar.bz2
Silence ResourceWarning when testing that the file destructor closes the file.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 7ce9753..d1973e5 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 = []