From 964ee2669e8c35b6c98c2275ccb981a46c57e85d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 13 Jul 2010 23:19:20 +0000 Subject: [PATCH] Merged revisions 82856-82857 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82856 | victor.stinner | 2010-07-14 01:04:56 +0200 (mer., 14 juil. 2010) | 2 lines Issue #9243: Fix sndhdr module and add unit tests, contributed by James Lee. ........ r82857 | victor.stinner | 2010-07-14 01:08:01 +0200 (mer., 14 juil. 2010) | 2 lines Woops, test_sndhdr.py contains the same code twice: fix it ........ --- Lib/sndhdr.py | 8 ++++---- Lib/test/sndhdrdata/README | 12 ++++++++++++ Lib/test/sndhdrdata/sndhdr.8svx | Bin 0 -> 110 bytes Lib/test/sndhdrdata/sndhdr.aifc | Bin 0 -> 106 bytes Lib/test/sndhdrdata/sndhdr.aiff | Bin 0 -> 108 bytes Lib/test/sndhdrdata/sndhdr.au | Bin 0 -> 64 bytes Lib/test/sndhdrdata/sndhdr.hcom | Bin 0 -> 256 bytes Lib/test/sndhdrdata/sndhdr.sndt | Bin 0 -> 129 bytes Lib/test/sndhdrdata/sndhdr.voc | Bin 0 -> 63 bytes Lib/test/sndhdrdata/sndhdr.wav | Bin 0 -> 64 bytes Misc/ACKS | 1 + Misc/NEWS | 2 ++ 12 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Lib/test/sndhdrdata/README create mode 100644 Lib/test/sndhdrdata/sndhdr.8svx create mode 100644 Lib/test/sndhdrdata/sndhdr.aifc create mode 100644 Lib/test/sndhdrdata/sndhdr.aiff create mode 100644 Lib/test/sndhdrdata/sndhdr.au create mode 100644 Lib/test/sndhdrdata/sndhdr.hcom create mode 100644 Lib/test/sndhdrdata/sndhdr.sndt create mode 100644 Lib/test/sndhdrdata/sndhdr.voc create mode 100644 Lib/test/sndhdrdata/sndhdr.wav diff --git a/Lib/sndhdr.py b/Lib/sndhdr.py index a8e0a0516663..9f5dcc90d439 100644 --- a/Lib/sndhdr.py +++ b/Lib/sndhdr.py @@ -57,12 +57,12 @@ tests = [] def test_aifc(h, f): import aifc - if h.startswith(b'FORM'): + if not h.startswith(b'FORM'): return None if h[8:12] == b'AIFC': fmt = 'aifc' elif h[8:12] == b'AIFF': - fmt = b'aiff' + fmt = 'aiff' else: return None f.seek(0) @@ -123,7 +123,7 @@ tests.append(test_hcom) def test_voc(h, f): - if h.startswith(b'Creative Voice File\032'): + if not h.startswith(b'Creative Voice File\032'): return None sbseek = get_short_le(h[20:22]) rate = 0 @@ -150,7 +150,7 @@ tests.append(test_wav) def test_8svx(h, f): - if h.startswith(b'FORM') or h[8:12] != b'8SVX': + if not h.startswith(b'FORM') or h[8:12] != b'8SVX': return None # Should decode it to get #channels -- assume always 1 return '8svx', 0, 1, 0, 8 diff --git a/Lib/test/sndhdrdata/README b/Lib/test/sndhdrdata/README new file mode 100644 index 000000000000..8a17c0041a46 --- /dev/null +++ b/Lib/test/sndhdrdata/README @@ -0,0 +1,12 @@ +Sound file samples used by Lib/test/test_sndhdr.py and generated using the +following commands: + + dd if=/dev/zero of=sndhdr.raw bs=20 count=1 + sox -s -2 -c 2 -r 44100 sndhdr.raw sndhdr. + +Sound file samples used by Lib/test/test_sndhdr.py and generated using the +following commands: + + dd if=/dev/zero of=sndhdr.raw bs=20 count=1 + sox -s -2 -c 2 -r 44100 sndhdr.raw sndhdr. + diff --git a/Lib/test/sndhdrdata/sndhdr.8svx b/Lib/test/sndhdrdata/sndhdr.8svx new file mode 100644 index 0000000000000000000000000000000000000000..8cd6cde5e09f356d47b031db7bae33697a6f751b GIT binary patch literal 110 zc-nLG5AtPTU`VqF4vPr$a0vpkMSz%<0SeZ*FfuRzk)xlVKai{7mYI{PkX)3SSdyBe wkW{GNih$gKYi0F2oc+5i9m literal 0 Hc-jL100001 diff --git a/Lib/test/sndhdrdata/sndhdr.aifc b/Lib/test/sndhdrdata/sndhdr.aifc new file mode 100644 index 0000000000000000000000000000000000000000..8aae4e730bdafeaf888a40d2e6950fab4de43ec5 GIT binary patch literal 106 zc-nLG5AtPTU`TTGbaQqKa}5HrSr#<}Iyn3Lg2dGrn1CcJgMb6y8W#pI@bmX`<;%-2 ZQAp0uEhtJYE>2Bh2oClG$;vR`0RT5j5OV+k literal 0 Hc-jL100001 diff --git a/Lib/test/sndhdrdata/sndhdr.aiff b/Lib/test/sndhdrdata/sndhdr.aiff new file mode 100644 index 0000000000000000000000000000000000000000..8c279a762f1c7074f9e91356b7b81b3da420db03 GIT binary patch literal 108 zc-nLG5AtPTU`TQFbaQj|_YDEEr5G4bB$=NDvIGK(@{?1Gi&Ik+k}4H~^CN&NK&pip Zn1CcJgMb6y8W#pI2oClGv1AzV005nl5B~rF literal 0 Hc-jL100001 diff --git a/Lib/test/sndhdrdata/sndhdr.au b/Lib/test/sndhdrdata/sndhdr.au new file mode 100644 index 0000000000000000000000000000000000000000..67c9e8fdd995efb47517e64f0f0dc98301f111ec GIT binary patch literal 64 tc-qq|&P!onV9)_#5g=w}U|8b