| 
									
										
										
										
											2009-03-26 21:10:30 +00:00
										 |  |  | from test.test_support import findfile, TestFailed, import_module | 
					
						
							|  |  |  | import unittest | 
					
						
							| 
									
										
										
										
											2008-05-16 00:10:24 +00:00
										 |  |  | sunaudiodev = import_module('sunaudiodev', deprecated=True) | 
					
						
							| 
									
										
										
										
											1997-01-07 21:05:29 +00:00
										 |  |  | import os | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-14 03:10:12 +00:00
										 |  |  | try: | 
					
						
							|  |  |  |     audiodev = os.environ["AUDIODEV"] | 
					
						
							|  |  |  | except KeyError: | 
					
						
							|  |  |  |     audiodev = "/dev/audio" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if not os.path.exists(audiodev): | 
					
						
							| 
									
										
										
										
											2009-03-26 21:10:30 +00:00
										 |  |  |     raise unittest.SkipTest("no audio device found!") | 
					
						
							| 
									
										
										
										
											2001-04-14 03:10:12 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-07 21:05:29 +00:00
										 |  |  | def play_sound_file(path): | 
					
						
							|  |  |  |     fp = open(path, 'r') | 
					
						
							|  |  |  |     data = fp.read() | 
					
						
							|  |  |  |     fp.close() | 
					
						
							| 
									
										
										
										
											1997-01-13 20:53:46 +00:00
										 |  |  |     try: | 
					
						
							| 
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 |  |  |         a = sunaudiodev.open('w') | 
					
						
							| 
									
										
										
										
											1997-01-13 20:53:46 +00:00
										 |  |  |     except sunaudiodev.error, msg: | 
					
						
							| 
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 |  |  |         raise TestFailed, msg | 
					
						
							| 
									
										
										
										
											1997-01-13 20:53:46 +00:00
										 |  |  |     else: | 
					
						
							| 
									
										
										
										
											1998-03-26 19:42:58 +00:00
										 |  |  |         a.write(data) | 
					
						
							|  |  |  |         a.close() | 
					
						
							| 
									
										
										
										
											1997-01-07 21:05:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-03 04:19:29 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | def test_main(): | 
					
						
							| 
									
										
										
										
											1997-01-13 20:34:44 +00:00
										 |  |  |     play_sound_file(findfile('audiotest.au')) | 
					
						
							| 
									
										
										
										
											1997-01-07 21:05:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-03 04:19:29 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     test_main() |