diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-26 13:50:50 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-26 13:50:50 (GMT) |
| commit | e46ef289e142982d7bd592faa7b0f85470364c01 (patch) | |
| tree | cda253e03788f7db0a7cdcd05662f66b4455e298 /src/python/stdlib/test/test_aifc.py | |
| parent | d0d0d62bbcbb5c3417f8cba419c83bac192ea985 (diff) | |
| download | powder-e46ef289e142982d7bd592faa7b0f85470364c01.zip powder-e46ef289e142982d7bd592faa7b0f85470364c01.tar.gz | |
Remove Python console stuff
Diffstat (limited to 'src/python/stdlib/test/test_aifc.py')
| -rw-r--r-- | src/python/stdlib/test/test_aifc.py | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/src/python/stdlib/test/test_aifc.py b/src/python/stdlib/test/test_aifc.py deleted file mode 100644 index cbf00e9..0000000 --- a/src/python/stdlib/test/test_aifc.py +++ /dev/null @@ -1,115 +0,0 @@ -from test.test_support import findfile, run_unittest, TESTFN -import unittest -import os - -import aifc - - -class AIFCTest(unittest.TestCase): - - def setUp(self): - self.f = self.fout = None - self.sndfilepath = findfile('Sine-1000Hz-300ms.aif') - - def tearDown(self): - if self.f is not None: - self.f.close() - if self.fout is not None: - try: - self.fout.close() - except (aifc.Error, AttributeError): - pass - try: - os.remove(TESTFN) - except OSError: - pass - - def test_skipunknown(self): - #Issue 2245 - #This file contains chunk types aifc doesn't recognize. - self.f = aifc.open(self.sndfilepath) - - def test_params(self): - f = self.f = aifc.open(self.sndfilepath) - self.assertEqual(f.getnchannels(), 2) - self.assertEqual(f.getsampwidth(), 2) - self.assertEqual(f.getframerate(), 48000) - self.assertEqual(f.getnframes(), 14400) - self.assertEqual(f.getcomptype(), 'NONE') - self.assertEqual(f.getcompname(), 'not compressed') - self.assertEqual(f.getparams(), (2, 2, 48000, 14400, 'NONE', 'not compressed')) - - def test_read(self): - f = self.f = aifc.open(self.sndfilepath) - self.assertEqual(f.tell(), 0) - self.assertEqual(f.readframes(2), '\x00\x00\x00\x00\x0b\xd4\x0b\xd4') - f.rewind() - pos0 = f.tell() - self.assertEqual(pos0, 0) - self.assertEqual(f.readframes(2), '\x00\x00\x00\x00\x0b\xd4\x0b\xd4') - pos2 = f.tell() - self.assertEqual(pos2, 2) - self.assertEqual(f.readframes(2), '\x17t\x17t"\xad"\xad') - f.setpos(pos2) - self.assertEqual(f.readframes(2), '\x17t\x17t"\xad"\xad') - f.setpos(pos0) - self.assertEqual(f.readframes(2), '\x00\x00\x00\x00\x0b\xd4\x0b\xd4') - - def test_write(self): - f = self.f = aifc.open(self.sndfilepath) - fout = self.fout = aifc.open(TESTFN, 'wb') - fout.aifc() - fout.setparams(f.getparams()) - for frame in range(f.getnframes()): - fout.writeframes(f.readframes(1)) - fout.close() - fout = self.fout = aifc.open(TESTFN, 'rb') - f.rewind() - self.assertEqual(f.getparams(), fout.getparams()) - self.assertEqual(f.readframes(5), fout.readframes(5)) - - def test_compress(self): - f = self.f = aifc.open(self.sndfilepath) - fout = self.fout = aifc.open(TESTFN, 'wb') - fout.aifc() - fout.setnchannels(f.getnchannels()) - fout.setsampwidth(f.getsampwidth()) - fout.setframerate(f.getframerate()) - fout.setcomptype('ULAW', 'foo') - for frame in range(f.getnframes()): - fout.writeframes(f.readframes(1)) - fout.close() - self.assertLess( - os.stat(TESTFN).st_size, - os.stat(self.sndfilepath).st_size*0.75, - ) - fout = self.fout = aifc.open(TESTFN, 'rb') - f.rewind() - self.assertEqual(f.getparams()[0:3], fout.getparams()[0:3]) - self.assertEqual(fout.getcomptype(), 'ULAW') - self.assertEqual(fout.getcompname(), 'foo') - # XXX: this test fails, not sure if it should succeed or not - # self.assertEqual(f.readframes(5), fout.readframes(5)) - - def test_close(self): - class Wrapfile(object): - def __init__(self, file): - self.file = open(file, 'rb') - self.closed = False - def close(self): - self.file.close() - self.closed = True - def __getattr__(self, attr): return getattr(self.file, attr) - testfile = Wrapfile(self.sndfilepath) - f = self.f = aifc.open(testfile) - self.assertEqual(testfile.closed, False) - f.close() - self.assertEqual(testfile.closed, True) - - -def test_main(): - run_unittest(AIFCTest) - - -if __name__ == "__main__": - unittest.main() |
