Merged revisions 82856-82857 via svnmerge from
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 13 Jul 2010 23:19:20 +0000 (23:19 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 13 Jul 2010 23:19:20 +0000 (23:19 +0000)
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
........

12 files changed:
Lib/sndhdr.py
Lib/test/sndhdrdata/README [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.8svx [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.aifc [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.aiff [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.au [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.hcom [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.sndt [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.voc [new file with mode: 0644]
Lib/test/sndhdrdata/sndhdr.wav [new file with mode: 0644]
Misc/ACKS
Misc/NEWS

index a8e0a05166631aa51804e83f6ed4bdf7e546e4e6..9f5dcc90d439947e31a2697d054280a9cb1c066b 100644 (file)
@@ -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 (file)
index 0000000..8a17c00
--- /dev/null
@@ -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.<format>
+
+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.<format>
+
diff --git a/Lib/test/sndhdrdata/sndhdr.8svx b/Lib/test/sndhdrdata/sndhdr.8svx
new file mode 100644 (file)
index 0000000..8cd6cde
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.8svx differ
diff --git a/Lib/test/sndhdrdata/sndhdr.aifc b/Lib/test/sndhdrdata/sndhdr.aifc
new file mode 100644 (file)
index 0000000..8aae4e7
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.aifc differ
diff --git a/Lib/test/sndhdrdata/sndhdr.aiff b/Lib/test/sndhdrdata/sndhdr.aiff
new file mode 100644 (file)
index 0000000..8c279a7
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.aiff differ
diff --git a/Lib/test/sndhdrdata/sndhdr.au b/Lib/test/sndhdrdata/sndhdr.au
new file mode 100644 (file)
index 0000000..67c9e8f
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.au differ
diff --git a/Lib/test/sndhdrdata/sndhdr.hcom b/Lib/test/sndhdrdata/sndhdr.hcom
new file mode 100644 (file)
index 0000000..debb02d
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.hcom differ
diff --git a/Lib/test/sndhdrdata/sndhdr.sndt b/Lib/test/sndhdrdata/sndhdr.sndt
new file mode 100644 (file)
index 0000000..e1ca9cb
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.sndt differ
diff --git a/Lib/test/sndhdrdata/sndhdr.voc b/Lib/test/sndhdrdata/sndhdr.voc
new file mode 100644 (file)
index 0000000..53a91fd
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.voc differ
diff --git a/Lib/test/sndhdrdata/sndhdr.wav b/Lib/test/sndhdrdata/sndhdr.wav
new file mode 100644 (file)
index 0000000..0dca367
Binary files /dev/null and b/Lib/test/sndhdrdata/sndhdr.wav differ
index 02f571a319be9f522dd40a62117e862bcc474da3..93af0165d2f86bd5fab30f13a03e46fa97ceaed3 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -433,6 +433,7 @@ Ben Laurie
 Simon Law
 Chris Lawrence
 Brian Leair
+James Lee
 John J. Lee
 Inyeol Lee
 Thomas Lee
index 7c264735c56374fc77513fdeed8605ae333f8dce..3717942737ae3012c2a7085e6afac971def2b30d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -78,6 +78,8 @@ C-API
 Library
 -------
 
+- Issue #9243: Fix sndhdr module and add unit tests, contributed by James Lee.
+
 - ``ast.literal_eval()`` now allows byte literals.
 
 - Issue #9137: Fix issue in MutableMapping.update, which incorrectly