Guido van Rossum | 8d691c8 | 2000-09-01 19:25:51 +0000 | [diff] [blame] | 1 | from test_support import verbose, findfile, TestFailed, TestSkipped |
Guido van Rossum | 3e06ab1 | 2000-06-29 19:35:29 +0000 | [diff] [blame] | 2 | import linuxaudiodev |
Guido van Rossum | 8d691c8 | 2000-09-01 19:25:51 +0000 | [diff] [blame] | 3 | import errno |
Guido van Rossum | 3e06ab1 | 2000-06-29 19:35:29 +0000 | [diff] [blame] | 4 | import os |
| 5 | |
| 6 | def play_sound_file(path): |
| 7 | fp = open(path, 'r') |
| 8 | data = fp.read() |
| 9 | fp.close() |
| 10 | try: |
| 11 | a = linuxaudiodev.open('w') |
| 12 | except linuxaudiodev.error, msg: |
Guido van Rossum | 8d691c8 | 2000-09-01 19:25:51 +0000 | [diff] [blame] | 13 | if msg[0] in (errno.EACCES, errno.ENODEV): |
| 14 | raise TestSkipped, msg |
Guido van Rossum | 3e06ab1 | 2000-06-29 19:35:29 +0000 | [diff] [blame] | 15 | raise TestFailed, msg |
| 16 | else: |
| 17 | a.write(data) |
| 18 | a.close() |
| 19 | |
| 20 | def test(): |
| 21 | play_sound_file(findfile('audiotest.au')) |
| 22 | |
| 23 | test() |