]> granicus.if.org Git - python/commitdiff
A slightly better test of sunaudiodev module. Include the audio data
authorBarry Warsaw <barry@python.org>
Mon, 13 Jan 1997 20:34:44 +0000 (20:34 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 13 Jan 1997 20:34:44 +0000 (20:34 +0000)
in the distribution.

Lib/test/audiotest.au [new file with mode: 0644]
Lib/test/test_sunaudiodev.py

diff --git a/Lib/test/audiotest.au b/Lib/test/audiotest.au
new file mode 100644 (file)
index 0000000..3077fdd
Binary files /dev/null and b/Lib/test/audiotest.au differ
index 586cfb95f124d44b689a96f35bd186aff9b0ad1d..4f3b7749265432f2e766091deccd9ca8463fbef8 100644 (file)
@@ -2,10 +2,13 @@ from test_support import verbose, TestFailed
 import sunaudiodev
 import os
 
-OS_AUDIO_DIRS = [
-    '/usr/demo/SOUND/sounds/',         # Solaris 2.x
-    ]
-
+def findfile(file):
+       if os.path.isabs(file): return file
+       import sys
+       for dn in sys.path:
+               fn = os.path.join(dn, file)
+               if os.path.exists(fn): return fn
+       return file
 
 def play_sound_file(path):
     fp = open(path, 'r')
@@ -16,23 +19,7 @@ def play_sound_file(path):
     a.close()
 
 def test():
-    for d in OS_AUDIO_DIRS:
-       try:
-           files = os.listdir(d)
-           break
-       except os.error:
-           pass
-    else:
-       # test couldn't be conducted on this platform
-       raise ImportError
-    for f in files:
-       path = os.path.join(d, f)
-       try:
-           play_sound_file(path)
-           break
-       except:
-           pass
-    else:
-       raise TestFailed, "couldn't play any sounds"
+    print os.getcwd()
+    play_sound_file(findfile('audiotest.au'))
 
 test()