summaryrefslogtreecommitdiffstats
path: root/Lib/test/audiotests.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:10:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:10:18 (GMT)
commit481c6dd79f8263e9f4ffd1baac2e8463f5fdfac3 (patch)
tree9dccc30f2fe6fb22dd7c88e6ac5389bc6ef2e64b /Lib/test/audiotests.py
parent1f56a94a9e725162a66053aa6df500f2be143d12 (diff)
parent85812bca211dda686666d4a88182d5f7587decbc (diff)
downloadcpython-481c6dd79f8263e9f4ffd1baac2e8463f5fdfac3.zip
cpython-481c6dd79f8263e9f4ffd1baac2e8463f5fdfac3.tar.gz
cpython-481c6dd79f8263e9f4ffd1baac2e8463f5fdfac3.tar.bz2
Issue #18919: Fixed resource leaks in audio tests.
Diffstat (limited to 'Lib/test/audiotests.py')
-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 60c6550..7b39269 100644
--- a/Lib/test/audiotests.py
+++ b/Lib/test/audiotests.py
@@ -191,18 +191,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