From: Barry Warsaw Date: Mon, 13 Jan 1997 20:34:44 +0000 (+0000) Subject: A slightly better test of sunaudiodev module. Include the audio data X-Git-Tag: v1.5a1~535 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b241c4219297ed4589e38e2cc48daf7504c0f3bf;p=thirdparty%2FPython%2Fcpython.git A slightly better test of sunaudiodev module. Include the audio data in the distribution. --- diff --git a/Lib/test/audiotest.au b/Lib/test/audiotest.au new file mode 100644 index 000000000000..3077fdd0af68 Binary files /dev/null and b/Lib/test/audiotest.au differ diff --git a/Lib/test/test_sunaudiodev.py b/Lib/test/test_sunaudiodev.py index 586cfb95f124..4f3b77492654 100644 --- a/Lib/test/test_sunaudiodev.py +++ b/Lib/test/test_sunaudiodev.py @@ -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()