blob: a7a5e24d4afb3c931a40dbf267be77c5c7fd764c [file] [log] [blame]
Guido van Rossuma00afc12000-10-09 20:05:59 +00001from test_support import TestFailed
2import os, tempfile
3import wave
4
5def check(t, msg=None):
6 if not t:
7 raise TestFailed, msg
8
9nchannels = 2
10sampwidth = 2
11framerate = 8000
12nframes = 100
13
14testfile = tempfile.mktemp()
15
16f = wave.open(testfile, 'w')
17f.setnchannels(nchannels)
18f.setsampwidth(sampwidth)
19f.setframerate(framerate)
20f.setnframes(nframes)
21output = '\0' * nframes * nchannels * sampwidth
22f.writeframes(output)
23f.close()
24
25f = wave.open(testfile, 'r')
26check(nchannels == f.getnchannels(), "nchannels")
27check(sampwidth == f.getsampwidth(), "sampwidth")
28check(framerate == f.getframerate(), "framerate")
29check(nframes == f.getnframes(), "nframes")
30input = f.readframes(nframes)
31check(input == output, "data")
32f.close()
33
34os.remove(testfile)