]> granicus.if.org Git - python/commitdiff
Issue #18919: Check warnings messages in the aifc module tests.
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 14 Oct 2013 17:05:33 +0000 (20:05 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 14 Oct 2013 17:05:33 +0000 (20:05 +0300)
Lib/test/test_aifc.py

index d569b7226dff445a0369919d560b7b4b18861aa0..b77354bb0705d03d1d4c0e6a204aeaf76e760b7b 100644 (file)
@@ -260,8 +260,10 @@ class AIFCLowLevelTest(unittest.TestCase):
         b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
         b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
         b += b'MARK' + struct.pack('>LhB', 3, 1, 1)
-        with self.assertWarns(UserWarning):
+        with self.assertWarns(UserWarning) as cm:
             f = aifc.open(io.BytesIO(b))
+        self.assertEqual(str(cm.warning), 'Warning: MARK chunk contains '
+                                          'only 0 markers instead of 1')
         self.assertEqual(f.getmarkers(), None)
 
     def test_read_comm_kludge_compname_even(self):
@@ -269,8 +271,9 @@ class AIFCLowLevelTest(unittest.TestCase):
         b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
         b += b'NONE' + struct.pack('B', 4) + b'even' + b'\x00'
         b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
-        with self.assertWarns(UserWarning):
+        with self.assertWarns(UserWarning) as cm:
             f = aifc.open(io.BytesIO(b))
+        self.assertEqual(str(cm.warning), 'Warning: bad COMM chunk size')
         self.assertEqual(f.getcompname(), b'even')
 
     def test_read_comm_kludge_compname_odd(self):
@@ -278,8 +281,9 @@ class AIFCLowLevelTest(unittest.TestCase):
         b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
         b += b'NONE' + struct.pack('B', 3) + b'odd'
         b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
-        with self.assertWarns(UserWarning):
+        with self.assertWarns(UserWarning) as cm:
             f = aifc.open(io.BytesIO(b))
+        self.assertEqual(str(cm.warning), 'Warning: bad COMM chunk size')
         self.assertEqual(f.getcompname(), b'odd')
 
     def test_write_params_raises(self):