summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_aifc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2012-12-29 20:36:23 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2012-12-29 20:36:23 (GMT)
commitf1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e (patch)
treecdec2e3f4296a649f50d612b0c316fdda75b002b /Lib/test/test_aifc.py
parentf2b9cf4e612551eec954ee42e4ae3f0dfde3fd03 (diff)
parent051722d554c7cab6ae93509f4939a03169d03ac1 (diff)
downloadcpython-f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e.zip
cpython-f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e.tar.gz
cpython-f1b63c6f0ef4074ea12bdbc535c8bc9738c9a78e.tar.bz2
Issue #16485: Fix file descriptor not being closed if file header patching fails on closing of aifc file.
Diffstat (limited to 'Lib/test/test_aifc.py')
-rw-r--r--Lib/test/test_aifc.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
index ad6f610..9c0e7b9 100644
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -112,6 +112,13 @@ class AIFCTest(unittest.TestCase):
self.assertEqual(testfile.closed, False)
f.close()
self.assertEqual(testfile.closed, True)
+ testfile = open(TESTFN, 'wb')
+ fout = aifc.open(testfile, 'wb')
+ self.assertFalse(testfile.closed)
+ with self.assertRaises(aifc.Error):
+ fout.close()
+ self.assertTrue(testfile.closed)
+ fout.close() # do nothing
def test_write_header_comptype_sampwidth(self):
for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):
@@ -286,11 +293,13 @@ class AIFCLowLevelTest(unittest.TestCase):
def test_write_header_raises(self):
fout = aifc.open(io.BytesIO(), 'wb')
self.assertRaises(aifc.Error, fout.close)
+ fout = aifc.open(io.BytesIO(), 'wb')
fout.setnchannels(1)
self.assertRaises(aifc.Error, fout.close)
+ fout = aifc.open(io.BytesIO(), 'wb')
+ fout.setnchannels(1)
fout.setsampwidth(1)
self.assertRaises(aifc.Error, fout.close)
- fout.initfp(None)
def test_write_header_comptype_raises(self):
for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):