diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-07-13 23:04:56 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-07-13 23:04:56 +0000 |
commit | e9ebde48cf5d7892794eacaeba683b308ce5a94b (patch) | |
tree | 7ca9edd545aaaf2cf36cad4fd1aa5c0ff3955538 /Lib/test/test_sndhdr.py | |
parent | 903396ee660679340e47f68d0da7b78d30c43480 (diff) | |
download | cpython-git-e9ebde48cf5d7892794eacaeba683b308ce5a94b.tar.gz |
Issue #9243: Fix sndhdr module and add unit tests, contributed by James Lee.
Diffstat (limited to 'Lib/test/test_sndhdr.py')
-rw-r--r-- | Lib/test/test_sndhdr.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Lib/test/test_sndhdr.py b/Lib/test/test_sndhdr.py new file mode 100644 index 0000000000..4b4c8573b5 --- /dev/null +++ b/Lib/test/test_sndhdr.py @@ -0,0 +1,47 @@ +import sndhdr +import unittest +from test.support import findfile + +class TestFormats(unittest.TestCase): + def test_data(self): + for filename, expected in ( + ('sndhdr.8svx', ('8svx', 0, 1, 0, 8)), + ('sndhdr.aifc', ('aifc', 44100, 2, 5, 16)), + ('sndhdr.aiff', ('aiff', 44100, 2, 5, 16)), + ('sndhdr.au', ('au', 44100, 2, 5.0, 16)), + ('sndhdr.hcom', ('hcom', 22050.0, 1, -1, 8)), + ('sndhdr.sndt', ('sndt', 44100, 1, 5, 8)), + ('sndhdr.voc', ('voc', 0, 1, -1, 8)), + ('sndhdr.wav', ('wav', 44100, 2, -1, 16)), + ): + filename = findfile(filename, subdir="sndhdrdata") + what = sndhdr.what(filename) + self.assertNotEqual(what, None, filename) + self.assertSequenceEqual(what, expected) + +if __name__ == '__main__': + unittest.main() + +import sndhdr +import unittest +from test.support import findfile + +class TestFormats(unittest.TestCase): + def test_data(self): + for filename, expected in ( + ('sndhdr.8svx', ('8svx', 0, 1, 0, 8)), + ('sndhdr.aifc', ('aifc', 44100, 2, 5, 16)), + ('sndhdr.aiff', ('aiff', 44100, 2, 5, 16)), + ('sndhdr.au', ('au', 44100, 2, 5.0, 16)), + ('sndhdr.hcom', ('hcom', 22050.0, 1, -1, 8)), + ('sndhdr.sndt', ('sndt', 44100, 1, 5, 8)), + ('sndhdr.voc', ('voc', 0, 1, -1, 8)), + ('sndhdr.wav', ('wav', 44100, 2, -1, 16)), + ): + filename = findfile(filename, subdir="sndhdrdata") + what = sndhdr.what(filename) + self.assertNotEqual(what, None, filename) + self.assertSequenceEqual(what, expected) + +if __name__ == '__main__': + unittest.main() |