blob: 586cfb95f124d44b689a96f35bd186aff9b0ad1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
from test_support import verbose, TestFailed
import sunaudiodev
import os
OS_AUDIO_DIRS = [
'/usr/demo/SOUND/sounds/', # Solaris 2.x
]
def play_sound_file(path):
fp = open(path, 'r')
data = fp.read()
fp.close()
a = sunaudiodev.open('w')
a.write(data)
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"
test()
|