blob: 1438c095bfefe64370cf95955705958cdb141617 [file] [log] [blame]
Barry Warsaw5bc697d1997-01-07 21:05:29 +00001from test_support import verbose, TestFailed
2import sunaudiodev
3import os
4
Barry Warsawb241c421997-01-13 20:34:44 +00005def findfile(file):
Guido van Rossum41360a41998-03-26 19:42:58 +00006 if os.path.isabs(file): return file
7 import sys
8 path = sys.path
9 try:
10 path = [os.path.dirname(__file__)] + path
11 except NameError:
12 pass
13 for dn in path:
14 fn = os.path.join(dn, file)
15 if os.path.exists(fn): return fn
16 return file
Barry Warsaw5bc697d1997-01-07 21:05:29 +000017
18def play_sound_file(path):
19 fp = open(path, 'r')
20 data = fp.read()
21 fp.close()
Barry Warsaw3de721d1997-01-13 20:53:46 +000022 try:
Guido van Rossum41360a41998-03-26 19:42:58 +000023 a = sunaudiodev.open('w')
Barry Warsaw3de721d1997-01-13 20:53:46 +000024 except sunaudiodev.error, msg:
Guido van Rossum41360a41998-03-26 19:42:58 +000025 raise TestFailed, msg
Barry Warsaw3de721d1997-01-13 20:53:46 +000026 else:
Guido van Rossum41360a41998-03-26 19:42:58 +000027 a.write(data)
28 a.close()
Barry Warsaw5bc697d1997-01-07 21:05:29 +000029
30def test():
Barry Warsawb241c421997-01-13 20:34:44 +000031 play_sound_file(findfile('audiotest.au'))
Barry Warsaw5bc697d1997-01-07 21:05:29 +000032
33test()