ยปCore Development>Code coverage>Lib/test/test_sndhdr.py

Python code coverage for Lib/test/test_sndhdr.py

#countcontent
1n/aimport sndhdr
2n/aimport pickle
3n/aimport unittest
4n/afrom test.support import findfile
5n/a
6n/aclass TestFormats(unittest.TestCase):
7n/a def test_data(self):
8n/a for filename, expected in (
9n/a ('sndhdr.8svx', ('8svx', 0, 1, 0, 8)),
10n/a ('sndhdr.aifc', ('aifc', 44100, 2, 5, 16)),
11n/a ('sndhdr.aiff', ('aiff', 44100, 2, 5, 16)),
12n/a ('sndhdr.au', ('au', 44100, 2, 5.0, 16)),
13n/a ('sndhdr.hcom', ('hcom', 22050.0, 1, -1, 8)),
14n/a ('sndhdr.sndt', ('sndt', 44100, 1, 5, 8)),
15n/a ('sndhdr.voc', ('voc', 0, 1, -1, 8)),
16n/a ('sndhdr.wav', ('wav', 44100, 2, 5, 16)),
17n/a ):
18n/a filename = findfile(filename, subdir="sndhdrdata")
19n/a what = sndhdr.what(filename)
20n/a self.assertNotEqual(what, None, filename)
21n/a self.assertSequenceEqual(what, expected)
22n/a self.assertEqual(what.filetype, expected[0])
23n/a self.assertEqual(what.framerate, expected[1])
24n/a self.assertEqual(what.nchannels, expected[2])
25n/a self.assertEqual(what.nframes, expected[3])
26n/a self.assertEqual(what.sampwidth, expected[4])
27n/a
28n/a def test_pickleable(self):
29n/a filename = findfile('sndhdr.aifc', subdir="sndhdrdata")
30n/a what = sndhdr.what(filename)
31n/a for proto in range(pickle.HIGHEST_PROTOCOL + 1):
32n/a dump = pickle.dumps(what, proto)
33n/a self.assertEqual(pickle.loads(dump), what)
34n/a
35n/a
36n/aif __name__ == '__main__':
37n/a unittest.main()