diff options
author | Guido van Rossum <guido@python.org> | 2000-10-09 20:05:59 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-10-09 20:05:59 (GMT) |
commit | a00afc1ead7d0c09d9407ccf06b4bedf8eade0a5 (patch) | |
tree | 13ab3e599126a638d185977727cdb7bd9215e0af /Lib/test | |
parent | 13a3069c2b77df9874d68b5afef97a81525b4ceb (diff) | |
download | cpython-a00afc1ead7d0c09d9407ccf06b4bedf8eade0a5.zip cpython-a00afc1ead7d0c09d9407ccf06b4bedf8eade0a5.tar.gz cpython-a00afc1ead7d0c09d9407ccf06b4bedf8eade0a5.tar.bz2 |
Simple test suite for wave.py by Jean-Claude Rimbault (with some
changes to avoid using assert).
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_wave.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py new file mode 100644 index 0000000..a7a5e24 --- /dev/null +++ b/Lib/test/test_wave.py @@ -0,0 +1,34 @@ +from test_support import TestFailed +import os, tempfile +import wave + +def check(t, msg=None): + if not t: + raise TestFailed, msg + +nchannels = 2 +sampwidth = 2 +framerate = 8000 +nframes = 100 + +testfile = tempfile.mktemp() + +f = wave.open(testfile, 'w') +f.setnchannels(nchannels) +f.setsampwidth(sampwidth) +f.setframerate(framerate) +f.setnframes(nframes) +output = '\0' * nframes * nchannels * sampwidth +f.writeframes(output) +f.close() + +f = wave.open(testfile, 'r') +check(nchannels == f.getnchannels(), "nchannels") +check(sampwidth == f.getsampwidth(), "sampwidth") +check(framerate == f.getframerate(), "framerate") +check(nframes == f.getnframes(), "nframes") +input = f.readframes(nframes) +check(input == output, "data") +f.close() + +os.remove(testfile) |