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