Kaydet (Commit) 2d562f80 authored tarafından Brett Cannon's avatar Brett Cannon

have test_asyncore properly close files.

üst 1ab58dfb
......@@ -397,7 +397,8 @@ class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
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 @@ class FileWrapperTest(unittest.TestCase):
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')
......
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