Guido van Rossum | 228b8e8 | 1997-04-02 06:13:34 +0000 | [diff] [blame] | 1 | from test_support import verbose, TestFailed |
| 2 | import sunaudiodev |
| 3 | import os |
| 4 | |
| 5 | def findfile(file): |
| 6 | if os.path.isabs(file): return file |
| 7 | import sys |
| 8 | for dn in sys.path: |
| 9 | fn = os.path.join(dn, file) |
| 10 | if os.path.exists(fn): return fn |
| 11 | return file |
| 12 | |
| 13 | def play_sound_file(path): |
| 14 | fp = open(path, 'r') |
| 15 | data = fp.read() |
| 16 | fp.close() |
| 17 | try: |
| 18 | a = sunaudiodev.open('w') |
| 19 | except sunaudiodev.error, msg: |
| 20 | raise TestFailed, msg |
| 21 | else: |
| 22 | a.write(data) |
| 23 | a.close() |
| 24 | |
| 25 | def test(): |
| 26 | play_sound_file(findfile('audiotest.au')) |
| 27 | |
| 28 | test() |