diff options
author | Brett Cannon <bcannon@gmail.com> | 2010-10-29 22:40:44 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2010-10-29 22:40:44 (GMT) |
commit | 2d562f80811bdb947eaf85430bbb550c7e845419 (patch) | |
tree | c5980e041fdd9c35019650061bdcd235c8b14608 | |
parent | 1ab58dfb12dedb7d8a92c8cc222a35bc844e8326 (diff) | |
download | cpython-2d562f80811bdb947eaf85430bbb550c7e845419.zip cpython-2d562f80811bdb947eaf85430bbb550c7e845419.tar.gz cpython-2d562f80811bdb947eaf85430bbb550c7e845419.tar.bz2 |
have test_asyncore properly close files.
-rw-r--r-- | Lib/test/test_asyncore.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index f2ec8b8..5450468 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -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') |