[Python-checkins] cpython (merge 3.3 -> default): Issue #18919: Check warnings messages in the aifc module tests.

serhiy.storchaka python-checkins at python.org
Mon Oct 14 19:06:37 CEST 2013


http://hg.python.org/cpython/rev/d168f094d16d
changeset:   86369:d168f094d16d
parent:      86366:0ee6543fb3f2
parent:      86368:9eecd00ffc28
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Oct 14 20:06:04 2013 +0300
summary:
  Issue #18919: Check warnings messages in the aifc module tests.

files:
  Lib/test/test_aifc.py |  10 +++++++---
  1 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -275,8 +275,10 @@
         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):
@@ -284,8 +286,9 @@
         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):
@@ -293,8 +296,9 @@
         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):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list