mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00

at all (my computer doesn't have a Sound Blaster), this doesn't mean there's a bug in linuxaudiodev. The only error the test suite skips is currently ImportError -- so that's what we raise. If you see a problem with this patch, say so and I'll retract. If you think raising an ImportError sucks, you're right -- but I ain't gonna buy a SB and I sure ain't gonna let the test-suite fail on my machine.
23 lines
486 B
Python
23 lines
486 B
Python
from test_support import verbose, findfile, TestFailed
|
|
import linuxaudiodev
|
|
import errno
|
|
import os
|
|
|
|
def play_sound_file(path):
|
|
fp = open(path, 'r')
|
|
data = fp.read()
|
|
fp.close()
|
|
try:
|
|
a = linuxaudiodev.open('w')
|
|
except linuxaudiodev.error, msg:
|
|
if msg[0] in (errno.EACCES, errno.ENODEV):
|
|
raise ImportError, msg
|
|
raise TestFailed, msg
|
|
else:
|
|
a.write(data)
|
|
a.close()
|
|
|
|
def test():
|
|
play_sound_file(findfile('audiotest.au'))
|
|
|
|
test()
|