A slightly better test of sunaudiodev module. Include the audio data

in the distribution.
This commit is contained in:
Barry Warsaw 1997-01-13 20:34:44 +00:00
parent dbfb8d4626
commit b241c42192
2 changed files with 9 additions and 22 deletions

BIN
Lib/test/audiotest.au Normal file

Binary file not shown.

View File

@ -2,10 +2,13 @@
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()