diff options
author | Barry Warsaw <barry@python.org> | 1997-01-07 21:05:29 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1997-01-07 21:05:29 (GMT) |
commit | 5bc697dd31afa898ddae9d0919b50e94f3426148 (patch) | |
tree | 091ce101992a2208c93b927efc12cbb73a932d16 /Lib | |
parent | dce1005908c197d5887692c73a5364e3c426412e (diff) | |
download | cpython-5bc697dd31afa898ddae9d0919b50e94f3426148.zip cpython-5bc697dd31afa898ddae9d0919b50e94f3426148.tar.gz cpython-5bc697dd31afa898ddae9d0919b50e94f3426148.tar.bz2 |
Test of the sunaudiodev module -- it simply plays a sound if it can
find one and doesn't output any data that can be verified. If it
can't find a sound file by looking in the standard Solaris locations
(which we can extend later), it raises an ImportError.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/output/test_sunaudiodev | 1 | ||||
-rw-r--r-- | Lib/test/test_sunaudiodev.py | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/Lib/test/output/test_sunaudiodev b/Lib/test/output/test_sunaudiodev new file mode 100644 index 0000000..eaf6805 --- /dev/null +++ b/Lib/test/output/test_sunaudiodev @@ -0,0 +1 @@ +test_sunaudiodev diff --git a/Lib/test/test_sunaudiodev.py b/Lib/test/test_sunaudiodev.py new file mode 100644 index 0000000..586cfb9 --- /dev/null +++ b/Lib/test/test_sunaudiodev.py @@ -0,0 +1,38 @@ +from test_support import verbose, TestFailed +import sunaudiodev +import os + +OS_AUDIO_DIRS = [ + '/usr/demo/SOUND/sounds/', # Solaris 2.x + ] + + +def play_sound_file(path): + fp = open(path, 'r') + data = fp.read() + fp.close() + a = sunaudiodev.open('w') + a.write(data) + a.close() + +def test(): + for d in OS_AUDIO_DIRS: + try: + files = os.listdir(d) + break + except os.error: + pass + else: + # test couldn't be conducted on this platform + raise ImportError + for f in files: + path = os.path.join(d, f) + try: + play_sound_file(path) + break + except: + pass + else: + raise TestFailed, "couldn't play any sounds" + +test() |