PageRenderTime 383ms CodeModel.GetById 141ms app.highlight 3ms RepoModel.GetById 158ms app.codeStats 0ms

/Lib/test/test_sunaudiodev.py

http://unladen-swallow.googlecode.com/
Python | 32 lines | 24 code | 8 blank | 0 comment | 3 complexity | ee4389e6ab5cb3906578540822fad310 MD5 | raw file
 1from test.test_support import findfile, TestFailed, TestSkipped, import_module
 2sunaudiodev = import_module('sunaudiodev', deprecated=True)
 3import os
 4
 5try:
 6    audiodev = os.environ["AUDIODEV"]
 7except KeyError:
 8    audiodev = "/dev/audio"
 9
10if not os.path.exists(audiodev):
11    raise TestSkipped("no audio device found!")
12
13def 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
26def test_main():
27    play_sound_file(findfile('audiotest.au'))
28
29
30
31if __name__ == '__main__':
32    test_main()