• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from test.test_support import findfile, TestFailed, import_module
2import unittest
3sunaudiodev = import_module('sunaudiodev', deprecated=True)
4import os
5
6try:
7    audiodev = os.environ["AUDIODEV"]
8except KeyError:
9    audiodev = "/dev/audio"
10
11if not os.path.exists(audiodev):
12    raise unittest.SkipTest("no audio device found!")
13
14def play_sound_file(path):
15    fp = open(path, 'r')
16    data = fp.read()
17    fp.close()
18    try:
19        a = sunaudiodev.open('w')
20    except sunaudiodev.error, msg:
21        raise TestFailed, msg
22    else:
23        a.write(data)
24        a.close()
25
26
27def test_main():
28    play_sound_file(findfile('audiotest.au'))
29
30
31
32if __name__ == '__main__':
33    test_main()
34