summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:09:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:09:30 (GMT)
commite1a8a40d1d3a11b51f4c2cf9ba1fd0824af0483b (patch)
tree700f5cdc38b9ff3654e2c59f66d1f1a42105645f
parentc72105c06d0d3b5c5f9ed41f4ad1e7b9ba98ee16 (diff)
downloadcpython-e1a8a40d1d3a11b51f4c2cf9ba1fd0824af0483b.zip
cpython-e1a8a40d1d3a11b51f4c2cf9ba1fd0824af0483b.tar.gz
cpython-e1a8a40d1d3a11b51f4c2cf9ba1fd0824af0483b.tar.bz2
Issue #18919: Fixed resource leaks in audio tests.
-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 3e18df1..9c4ce6c 100644
--- a/Lib/test/audiotests.py
+++ b/Lib/test/audiotests.py
@@ -145,18 +145,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