diff options
author | R. David Murray <rdmurray@bitdance.com> | 2009-04-29 15:34:32 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2009-04-29 15:34:32 (GMT) |
commit | b507d2e07d19692df25a07c82f6d96ff1e4b4313 (patch) | |
tree | ce4801b966c66fb22166eea7230b6b36a89d7f1d /Lib/test | |
parent | aa17a7fc98773e0f2b2a23e59a0a2b3d9f1bca84 (diff) | |
download | cpython-b507d2e07d19692df25a07c82f6d96ff1e4b4313.zip cpython-b507d2e07d19692df25a07c82f6d96ff1e4b4313.tar.gz cpython-b507d2e07d19692df25a07c82f6d96ff1e4b4313.tar.bz2 |
Merged revisions 72100-72101 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72100 | r.david.murray | 2009-04-29 09:17:37 -0400 (Wed, 29 Apr 2009) | 7 lines
Fix issue 2245. aifc now skips any chunk type it doesn't actually
process instead of throwing errors for anything not in an explicit
skip list. This is per this spec: http://www.cnpbagwell.com/aiff-c.txt.
Spec reference and test sound file provided by Santiago Peresón, fix
based on patch by Hiroaki Kawai.
........
r72101 | r.david.murray | 2009-04-29 09:51:44 -0400 (Wed, 29 Apr 2009) | 2 lines
Now that we've got a test_aifc, add a few tests.
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/Sine-1000Hz-300ms.aif | bin | 0 -> 61696 bytes | |||
-rw-r--r-- | Lib/test/test_aifc.py | 59 | ||||
-rw-r--r-- | Lib/test/test_sundry.py | 1 |
3 files changed, 59 insertions, 1 deletions
diff --git a/Lib/test/Sine-1000Hz-300ms.aif b/Lib/test/Sine-1000Hz-300ms.aif Binary files differnew file mode 100644 index 0000000..bf08f5c --- /dev/null +++ b/Lib/test/Sine-1000Hz-300ms.aif diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py new file mode 100644 index 0000000..fd41126 --- /dev/null +++ b/Lib/test/test_aifc.py @@ -0,0 +1,59 @@ +from test.support import findfile, run_unittest +import unittest + +import aifc + + +class AIFCTest(unittest.TestCase): + + def setUp(self): + self.sndfilepath = findfile('Sine-1000Hz-300ms.aif') + + def test_skipunknown(self): + #Issue 2245 + #This file contains chunk types aifc doesn't recognize. + f = aifc.open(self.sndfilepath) + f.close() + + def test_params(self): + f = aifc.open(self.sndfilepath) + self.assertEqual(f.getnchannels(), 2) + self.assertEqual(f.getsampwidth(), 2) + self.assertEqual(f.getframerate(), 48000) + self.assertEqual(f.getnframes(), 14400) + # XXX: are the next two correct? The docs say/imply they are supposed + # to be strings. + self.assertEqual(f.getcomptype(), b'NONE') + self.assertEqual(f.getcompname(), b'not compressed') + self.assertEqual( + f.getparams(), + (2, 2, 48000, 14400, b'NONE', b'not compressed'), + ) + f.close() + + def test_read(self): + f = aifc.open(self.sndfilepath) + self.assertEqual(f.tell(), 0) + self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4') + f.rewind() + pos0 = f.tell() + self.assertEqual(pos0, 0) + self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4') + pos2 = f.tell() + self.assertEqual(pos2, 2) + self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad') + f.setpos(pos2) + self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad') + f.setpos(pos0) + self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4') + f.close() + + #XXX Need more tests! + + +def test_main(): + run_unittest(AIFCTest) + + +if __name__ == "__main__": + unittest.main() diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index bba54fe..ee387c7 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -9,7 +9,6 @@ class TestUntestedModules(unittest.TestCase): def test_at_least_import_untested_modules(self): with warnings.catch_warnings(): warnings.simplefilter("ignore") - import aifc import bdb import cgitb import code |