Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f56a94

Browse files
Issue #18919: Check warnings messages in the aifc module tests.
2 parents fb0b5f2 + 4606d36 commit 1f56a94

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/test/test_aifc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,26 +275,30 @@ def test_read_wrong_marks(self):
275275
b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
276276
b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
277277
b += b'MARK' + struct.pack('>LhB', 3, 1, 1)
278-
with self.assertWarns(UserWarning):
278+
with self.assertWarns(UserWarning) as cm:
279279
f = aifc.open(io.BytesIO(b))
280+
self.assertEqual(str(cm.warning), 'Warning: MARK chunk contains '
281+
'only 0 markers instead of 1')
280282
self.assertEqual(f.getmarkers(), None)
281283

282284
def test_read_comm_kludge_compname_even(self):
283285
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
284286
b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
285287
b += b'NONE' + struct.pack('B', 4) + b'even' + b'\x00'
286288
b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
287-
with self.assertWarns(UserWarning):
289+
with self.assertWarns(UserWarning) as cm:
288290
f = aifc.open(io.BytesIO(b))
291+
self.assertEqual(str(cm.warning), 'Warning: bad COMM chunk size')
289292
self.assertEqual(f.getcompname(), b'even')
290293

291294
def test_read_comm_kludge_compname_odd(self):
292295
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
293296
b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
294297
b += b'NONE' + struct.pack('B', 3) + b'odd'
295298
b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
296-
with self.assertWarns(UserWarning):
299+
with self.assertWarns(UserWarning) as cm:
297300
f = aifc.open(io.BytesIO(b))
301+
self.assertEqual(str(cm.warning), 'Warning: bad COMM chunk size')
298302
self.assertEqual(f.getcompname(), b'odd')
299303

300304
def test_write_params_raises(self):

0 commit comments

Comments
 (0)