Issue #6615: logging: Used weak references in internal handler list. Thanks to flox...
[python.git] / Lib / test / test_wave.py
blob02f5fae4df33489ce42312cb7362602bc53fdc04
1 from test.test_support import TESTFN, run_unittest
2 import os
3 import wave
4 import unittest
6 nchannels = 2
7 sampwidth = 2
8 framerate = 8000
9 nframes = 100
11 class TestWave(unittest.TestCase):
13 def setUp(self):
14 self.f = None
16 def tearDown(self):
17 if self.f is not None:
18 self.f.close()
19 try:
20 os.remove(TESTFN)
21 except OSError:
22 pass
24 def test_it(self):
25 self.f = wave.open(TESTFN, 'wb')
26 self.f.setnchannels(nchannels)
27 self.f.setsampwidth(sampwidth)
28 self.f.setframerate(framerate)
29 self.f.setnframes(nframes)
30 output = '\0' * nframes * nchannels * sampwidth
31 self.f.writeframes(output)
32 self.f.close()
34 self.f = wave.open(TESTFN, 'rb')
35 self.assertEqual(nchannels, self.f.getnchannels())
36 self.assertEqual(sampwidth, self.f.getsampwidth())
37 self.assertEqual(framerate, self.f.getframerate())
38 self.assertEqual(nframes, self.f.getnframes())
39 self.assertEqual(self.f.readframes(nframes), output)
41 def test_main():
42 run_unittest(TestWave)
44 if __name__ == '__main__':
45 test_main()