summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:06:04 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-14 17:06:04 (GMT)
commit1f56a94a9e725162a66053aa6df500f2be143d12 (patch)
tree708dec1e1398c8c5ef5e22f6a65b06b847876014
parentfb0b5f20bd0c5ffc58995e2fed1b7d01e3e2afb0 (diff)
parent4606d36d7f8e0e7c639bdd4aa70f09902160f893 (diff)
downloadcpython-1f56a94a9e725162a66053aa6df500f2be143d12.zip
cpython-1f56a94a9e725162a66053aa6df500f2be143d12.tar.gz
cpython-1f56a94a9e725162a66053aa6df500f2be143d12.tar.bz2
Issue #18919: Check warnings messages in the aifc module tests.
-rw-r--r--Lib/test/test_aifc.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
index 85a86c2..3e9a1d1 100644
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -275,8 +275,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):
@@ -284,8 +286,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):
@@ -293,8 +296,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):