[Python-checkins] r85944 - python/branches/py3k/Lib/test/test_asyncore.py
brett.cannon
python-checkins at python.org
Sat Oct 30 00:40:44 CEST 2010
Author: brett.cannon
Date: Sat Oct 30 00:40:44 2010
New Revision: 85944
Log:
have test_asyncore properly close files.
Modified:
python/branches/py3k/Lib/test/test_asyncore.py
Modified: python/branches/py3k/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k/Lib/test/test_asyncore.py (original)
+++ python/branches/py3k/Lib/test/test_asyncore.py Sat Oct 30 00:40:44 2010
@@ -397,7 +397,8 @@
class FileWrapperTest(unittest.TestCase):
def setUp(self):
self.d = b"It's not dead, it's sleeping!"
- open(TESTFN, 'wb').write(self.d)
+ with open(TESTFN, 'wb') as file:
+ file.write(self.d)
def tearDown(self):
unlink(TESTFN)
@@ -424,7 +425,8 @@
w.write(d1)
w.send(d2)
w.close()
- self.assertEqual(open(TESTFN, 'rb').read(), self.d + d1 + d2)
+ with open(TESTFN, 'rb') as file:
+ self.assertEqual(file.read(), self.d + d1 + d2)
@unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'),
'asyncore.file_dispatcher required')
More information about the Python-checkins
mailing list