Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_wave.py @ 65035:87f4b32905df 2.7
Cosmetic fix to use print function.
| author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> |
|---|---|
| date | Fri, 01 Oct 2010 10:48:47 +0000 |
| parents | 8bc1fdc63370 |
| children | a9f967c8d002 |
| rev | line source |
|---|---|
|
45178
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
1 from test.test_support import TESTFN, run_unittest |
|
24710
11c701038805
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Guido van Rossum <guido@python.org>
parents:
24364
diff
changeset
|
2 import os |
|
15124
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 import wave |
|
45178
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
4 import unittest |
|
15124
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 nchannels = 2 |
|
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 sampwidth = 2 |
|
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 framerate = 8000 |
|
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 nframes = 100 |
|
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
45178
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
11 class TestWave(unittest.TestCase): |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
12 |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
13 def setUp(self): |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
14 self.f = None |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
15 |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
16 def tearDown(self): |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
17 if self.f is not None: |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
18 self.f.close() |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
19 try: |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
20 os.remove(TESTFN) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
21 except OSError: |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
22 pass |
|
15124
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 |
|
45178
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
24 def test_it(self): |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
25 self.f = wave.open(TESTFN, 'wb') |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
26 self.f.setnchannels(nchannels) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
27 self.f.setsampwidth(sampwidth) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
28 self.f.setframerate(framerate) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
29 self.f.setnframes(nframes) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
30 output = '\0' * nframes * nchannels * sampwidth |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
31 self.f.writeframes(output) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
32 self.f.close() |
|
15124
3ae9d313bc33
Simple test suite for wave.py by Jean-Claude Rimbault (with some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
45178
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
34 self.f = wave.open(TESTFN, 'rb') |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
35 self.assertEqual(nchannels, self.f.getnchannels()) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
36 self.assertEqual(sampwidth, self.f.getsampwidth()) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
37 self.assertEqual(framerate, self.f.getframerate()) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
38 self.assertEqual(nframes, self.f.getnframes()) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
39 self.assertEqual(self.f.readframes(nframes), output) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
40 |
| 45179 | 41 def test_main(): |
|
45178
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
42 run_unittest(TestWave) |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
43 |
|
68636ea89153
Issue 1951. Converts wave test cases to unittest.
Facundo Batista <facundobatista@gmail.com>
parents:
24710
diff
changeset
|
44 if __name__ == '__main__': |
| 45179 | 45 test_main() |
