summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:09:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:09:47 (GMT)
commit85812bca211dda686666d4a88182d5f7587decbc (patch)
treea9fa8930b7d562b16e0b541b3726133f7e5130d4 /Lib/test
parent4606d36d7f8e0e7c639bdd4aa70f09902160f893 (diff)
downloadcpython-85812bca211dda686666d4a88182d5f7587decbc.zip
cpython-85812bca211dda686666d4a88182d5f7587decbc.tar.gz
cpython-85812bca211dda686666d4a88182d5f7587decbc.tar.bz2
Issue #18919: Fixed resource leaks in audio tests.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/audiotests.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/audiotests.py b/Lib/test/audiotests.py
index 147cda0..59e99287 100644
--- a/Lib/test/audiotests.py
+++ b/Lib/test/audiotests.py
@@ -141,18 +141,18 @@ class AudioTestsWithSourceFile(AudioTests):
self.sndfilenframes, self.comptype, self.compname)
def test_close(self):
- testfile = open(self.sndfilepath, 'rb')
- f = self.f = self.module.open(testfile)
- self.assertFalse(testfile.closed)
- f.close()
- self.assertEqual(testfile.closed, self.close_fd)
- testfile = open(TESTFN, 'wb')
- fout = self.module.open(testfile, 'wb')
- self.assertFalse(testfile.closed)
- with self.assertRaises(self.module.Error):
- fout.close()
- self.assertEqual(testfile.closed, self.close_fd)
- fout.close() # do nothing
+ with open(self.sndfilepath, 'rb') as testfile:
+ f = self.f = self.module.open(testfile)
+ self.assertFalse(testfile.closed)
+ f.close()
+ self.assertEqual(testfile.closed, self.close_fd)
+ with open(TESTFN, 'wb') as testfile:
+ fout = self.fout = self.module.open(testfile, 'wb')
+ self.assertFalse(testfile.closed)
+ with self.assertRaises(self.module.Error):
+ fout.close()
+ self.assertEqual(testfile.closed, self.close_fd)
+ fout.close() # do nothing
def test_read(self):
framesize = self.nchannels * self.sampwidth