annotate Lib/test/test_sunaudiodev.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 57aed16e2165
children 0bd185c2e581
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4915
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
1 from test_support import verbose, TestFailed
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
2 import sunaudiodev
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
3 import os
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
4
4941
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
5 def findfile(file):
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
6 if os.path.isabs(file): return file
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
7 import sys
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
8 for dn in sys.path:
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
9 fn = os.path.join(dn, file)
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
10 if os.path.exists(fn): return fn
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
11 return file
4915
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
12
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
13 def play_sound_file(path):
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
14 fp = open(path, 'r')
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
15 data = fp.read()
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
16 fp.close()
4943
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
17 try:
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
18 a = sunaudiodev.open('w')
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
19 except sunaudiodev.error, msg:
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
20 raise TestFailed, msg
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
21 else:
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
22 a.write(data)
57aed16e2165 Catch sunaudiodev.error on open() and re-raise TestFailed exception.
Barry Warsaw <barry@python.org>
parents: 4942
diff changeset
23 a.close()
4915
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
24
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
25 def test():
4941
33e33ba7f421 A slightly better test of sunaudiodev module. Include the audio data
Barry Warsaw <barry@python.org>
parents: 4915
diff changeset
26 play_sound_file(findfile('audiotest.au'))
4915
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
27
14ed909a9c80 Test of the sunaudiodev module -- it simply plays a sound if it can
Barry Warsaw <barry@python.org>
parents:
diff changeset
28 test()