diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-14 20:03:06 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-14 20:03:06 +0300 |
commit | c72105c06d0d3b5c5f9ed41f4ad1e7b9ba98ee16 (patch) | |
tree | b83d78bb665e73592010858c3423762f39386289 /Lib/test/test_aifc.py | |
parent | 62e95802199c354833ec130b332e44333b8996aa (diff) | |
download | cpython-git-c72105c06d0d3b5c5f9ed41f4ad1e7b9ba98ee16.tar.gz |
Issue #18919: Catch and check warnings in the aifc module tests.
Diffstat (limited to 'Lib/test/test_aifc.py')
-rw-r--r-- | Lib/test/test_aifc.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py index d1e2cdccbd..a312d31b9e 100644 --- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -1,4 +1,5 @@ -from test.test_support import findfile, TESTFN, unlink, run_unittest +from test.test_support import (findfile, TESTFN, unlink, captured_stdout, + run_unittest) import unittest from test import audiotests import os @@ -225,7 +226,10 @@ class AIFCLowLevelTest(unittest.TestCase): b += 'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0) b += 'SSND' + struct.pack('>L', 8) + '\x00' * 8 b += 'MARK' + struct.pack('>LhB', 3, 1, 1) - f = aifc.open(io.BytesIO(b)) + with captured_stdout() as s: + f = aifc.open(io.BytesIO(b)) + self.assertEqual(s.getvalue(), 'Warning: MARK chunk contains ' + 'only 0 markers instead of 1\n') self.assertEqual(f.getmarkers(), None) def test_read_comm_kludge_compname_even(self): @@ -233,7 +237,9 @@ class AIFCLowLevelTest(unittest.TestCase): b += 'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0) b += 'NONE' + struct.pack('B', 4) + 'even' + '\x00' b += 'SSND' + struct.pack('>L', 8) + '\x00' * 8 - f = aifc.open(io.BytesIO(b)) + with captured_stdout() as s: + f = aifc.open(io.BytesIO(b)) + self.assertEqual(s.getvalue(), 'Warning: bad COMM chunk size\n') self.assertEqual(f.getcompname(), 'even') def test_read_comm_kludge_compname_odd(self): @@ -241,7 +247,9 @@ class AIFCLowLevelTest(unittest.TestCase): b += 'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0) b += 'NONE' + struct.pack('B', 3) + 'odd' b += 'SSND' + struct.pack('>L', 8) + '\x00' * 8 - f = aifc.open(io.BytesIO(b)) + with captured_stdout() as s: + f = aifc.open(io.BytesIO(b)) + self.assertEqual(s.getvalue(), 'Warning: bad COMM chunk size\n') self.assertEqual(f.getcompname(), 'odd') def test_write_params_raises(self): |