Skip to content

Commit 4606d36

Browse files
Issue #18919: Check warnings messages in the aifc module tests.
1 parent d98d6cb commit 4606d36

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/test/test_aifc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,30 @@ def test_read_wrong_marks(self):
260260
b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
261261
b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
262262
b += b'MARK' + struct.pack('>LhB', 3, 1, 1)
263-
with self.assertWarns(UserWarning):
263+
with self.assertWarns(UserWarning) as cm:
264264
f = aifc.open(io.BytesIO(b))
265+
self.assertEqual(str(cm.warning), 'Warning: MARK chunk contains '
266+
'only 0 markers instead of 1')
265267
self.assertEqual(f.getmarkers(), None)
266268

267269
def test_read_comm_kludge_compname_even(self):
268270
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
269271
b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
270272
b += b'NONE' + struct.pack('B', 4) + b'even' + b'\x00'
271273
b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
272-
with self.assertWarns(UserWarning):
274+
with self.assertWarns(UserWarning) as cm:
273275
f = aifc.open(io.BytesIO(b))
276+
self.assertEqual(str(cm.warning), 'Warning: bad COMM chunk size')
274277
self.assertEqual(f.getcompname(), b'even')
275278

276279
def test_read_comm_kludge_compname_odd(self):
277280
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
278281
b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
279282
b += b'NONE' + struct.pack('B', 3) + b'odd'
280283
b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
281-
with self.assertWarns(UserWarning):
284+
with self.assertWarns(UserWarning) as cm:
282285
f = aifc.open(io.BytesIO(b))
286+
self.assertEqual(str(cm.warning), 'Warning: bad COMM chunk size')
283287
self.assertEqual(f.getcompname(), b'odd')
284288

285289
def test_write_params_raises(self):

0 commit comments

Comments
 (0)