home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 July / maximum-cd-2011-07.iso / DiscContents / LibO_3.3.2_Win_x86_install_multi.exe / libreoffice1.cab / test_sunaudiodev.py < prev    next >
Encoding:
Python Source  |  2011-03-15  |  678 b   |  33 lines

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