diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-07-25 20:12:01 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-07-25 20:12:01 (GMT) |
commit | 4d35e75ca069b51ffdac7b34dad4ffb77e72a598 (patch) | |
tree | 0b5cbaf639fc047ed4fd464371fcef2f8ccdcf13 /Lib/test/test_aifc.py | |
parent | 840c310a2577459dd9f6ac9f5f9b136d7f4829f8 (diff) | |
download | cpython-4d35e75ca069b51ffdac7b34dad4ffb77e72a598.zip cpython-4d35e75ca069b51ffdac7b34dad4ffb77e72a598.tar.gz cpython-4d35e75ca069b51ffdac7b34dad4ffb77e72a598.tar.bz2 |
#17818: aifc.getparams now returns a namedtuple.
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/test_aifc.py')
-rw-r--r-- | Lib/test/test_aifc.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py index 98d43e4..05e4ca0 100644 --- a/Lib/test/test_aifc.py +++ b/Lib/test/test_aifc.py @@ -3,6 +3,7 @@ import unittest import os import io import struct +import pickle import aifc @@ -31,6 +32,7 @@ class AIFCTest(unittest.TestCase): def test_params(self): f = self.f = aifc.open(self.sndfilepath) + params = f.getparams() self.assertEqual(f.getfp().name, self.sndfilepath) self.assertEqual(f.getnchannels(), 2) self.assertEqual(f.getsampwidth(), 2) @@ -43,6 +45,36 @@ class AIFCTest(unittest.TestCase): (2, 2, 48000, 14400, b'NONE', b'not compressed'), ) + params = f.getparams() + self.assertEqual(params.nchannels, 2) + self.assertEqual(params.sampwidth, 2) + self.assertEqual(params.framerate, 48000) + self.assertEqual(params.nframes, 14400) + self.assertEqual(params.comptype, b'NONE') + self.assertEqual(params.compname, b'not compressed') + + def test_params_added(self): + f = self.f = aifc.open(TESTFN, 'wb') + f.aiff() + f.setparams((1, 1, 1, 1, b'NONE', b'')) + f.close() + + f = self.f = aifc.open(TESTFN, 'rb') + params = f.getparams() + self.assertEqual(params.nchannels, f.getnchannels()) + self.assertEqual(params.sampwidth, f.getsampwidth()) + self.assertEqual(params.framerate, f.getframerate()) + self.assertEqual(params.nframes, f.getnframes()) + self.assertEqual(params.comptype, f.getcomptype()) + self.assertEqual(params.compname, f.getcompname()) + + def test_getparams_picklable(self): + self.f = aifc.open(self.sndfilepath) + params = self.f.getparams() + dump = pickle.dumps(params) + self.assertEqual(pickle.loads(dump), params) + self.f.close() + def test_context_manager(self): with open(self.sndfilepath, 'rb') as testfile: with aifc.open(testfile) as f: |