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