77import sys
88import struct
99import aifc
10+ from test .test_support import check_warnings
1011
1112
1213class AifcTest (audiotests .AudioWriteTests ,
@@ -237,7 +238,7 @@ def test_read_wrong_number_of_channels(self):
237238 0x4000 | 12 , 11025 << 18 , 0 )
238239 b += b'NONE' + struct .pack ('B' , 14 ) + b'not compressed' + b'\x00 '
239240 b += b'SSND' + struct .pack ('>L' , 8 ) + b'\x00 ' * 8
240- with self .assertRaisesRegex (aifc .Error , 'bad # of channels' ):
241+ with self .assertRaisesRegexp (aifc .Error , 'bad # of channels' ):
241242 aifc .open (io .BytesIO (b ))
242243
243244 def test_read_wrong_sample_width (self ):
@@ -247,7 +248,7 @@ def test_read_wrong_sample_width(self):
247248 0x4000 | 12 , 11025 << 18 , 0 )
248249 b += b'NONE' + struct .pack ('B' , 14 ) + b'not compressed' + b'\x00 '
249250 b += b'SSND' + struct .pack ('>L' , 8 ) + b'\x00 ' * 8
250- with self .assertRaisesRegex (aifc .Error , 'bad sample width' ):
251+ with self .assertRaisesRegexp (aifc .Error , 'bad sample width' ):
251252 aifc .open (io .BytesIO (b ))
252253
253254 def test_read_wrong_marks (self ):
@@ -256,21 +257,18 @@ def test_read_wrong_marks(self):
256257 0x4000 | 12 , 11025 << 18 , 0 )
257258 b += b'SSND' + struct .pack ('>L' , 8 ) + b'\x00 ' * 8
258259 b += b'MARK' + struct .pack ('>LhB' , 3 , 1 , 1 )
259- with self . assertWarns ( UserWarning ) as cm :
260+ with check_warnings (( 'MARK chunk contains only 0 markers instead of 1' , UserWarning )) :
260261 f = aifc .open (io .BytesIO (b ))
261- self .assertEqual (s .getvalue (), 'Warning: MARK chunk contains '
262- 'only 0 markers instead of 1\n ' )
263- self .assertEqual (f .getmarkers (), None )
262+ self .assertEqual (f .getmarkers (), None )
264263
265264 def test_read_comm_kludge_compname_even (self ):
266265 b = b'FORM' + struct .pack ('>L' , 4 ) + b'AIFC'
267266 b += b'COMM' + struct .pack ('>LhlhhLL' , 18 , 1 , 0 , 8 ,
268267 0x4000 | 12 , 11025 << 18 , 0 )
269268 b += b'NONE' + struct .pack ('B' , 4 ) + b'even' + b'\x00 '
270269 b += b'SSND' + struct .pack ('>L' , 8 ) + b'\x00 ' * 8
271- with self . assertWarns ( UserWarning ) as cm :
270+ with check_warnings (( 'bad COMM chunk size' , UserWarning )) :
272271 f = aifc .open (io .BytesIO (b ))
273- self .assertEqual (s .getvalue (), 'Warning: bad COMM chunk size\n ' )
274272 self .assertEqual (f .getcompname (), 'even' )
275273
276274 def test_read_comm_kludge_compname_odd (self ):
@@ -279,9 +277,8 @@ def test_read_comm_kludge_compname_odd(self):
279277 0x4000 | 12 , 11025 << 18 , 0 )
280278 b += b'NONE' + struct .pack ('B' , 3 ) + b'odd'
281279 b += b'SSND' + struct .pack ('>L' , 8 ) + b'\x00 ' * 8
282- with self . assertWarns ( UserWarning ) as cm :
280+ with check_warnings (( 'bad COMM chunk size' , UserWarning )) :
283281 f = aifc .open (io .BytesIO (b ))
284- self .assertEqual (s .getvalue (), 'Warning: bad COMM chunk size\n ' )
285282 self .assertEqual (f .getcompname (), 'odd' )
286283
287284 def test_write_params_raises (self ):
0 commit comments