Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_aifc.AIFCTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_skipunknown
def test_params
def test_read
def test_write
def test_compress
def test_close

Public Attributes

 f
 fout
 sndfilepath
 file
 closed

Detailed Description

Definition at line 8 of file test_aifc.py.


Member Function Documentation

Definition at line 10 of file test_aifc.py.

00010 
00011     def setUp(self):
00012         self.f = self.fout = None
00013         self.sndfilepath = findfile('Sine-1000Hz-300ms.aif')

Here is the caller graph for this function:

Definition at line 14 of file test_aifc.py.

00014 
00015     def tearDown(self):
00016         if self.f is not None:
00017             self.f.close()
00018         if self.fout is not None:
00019             try:
00020                 self.fout.close()
00021             except (aifc.Error, AttributeError):
00022                 pass
00023         try:
00024             os.remove(TESTFN)
00025         except OSError:
00026             pass

Here is the caller graph for this function:

Definition at line 97 of file test_aifc.py.

00097 
00098     def test_close(self):
00099         class Wrapfile(object):
00100             def __init__(self, file):
00101                 self.file = open(file, 'rb')
00102                 self.closed = False
00103             def close(self):
00104                 self.file.close()
00105                 self.closed = True
00106             def __getattr__(self, attr): return getattr(self.file, attr)
00107         testfile = Wrapfile(self.sndfilepath)
00108         f = self.f = aifc.open(testfile)
00109         self.assertEqual(testfile.closed, False)
00110         f.close()
00111         self.assertEqual(testfile.closed, True)
00112 

Here is the call graph for this function:

Definition at line 74 of file test_aifc.py.

00074 
00075     def test_compress(self):
00076         f = self.f = aifc.open(self.sndfilepath)
00077         fout = self.fout = aifc.open(TESTFN, 'wb')
00078         fout.aifc()
00079         fout.setnchannels(f.getnchannels())
00080         fout.setsampwidth(f.getsampwidth())
00081         fout.setframerate(f.getframerate())
00082         fout.setcomptype(b'ULAW', b'foo')
00083         for frame in range(f.getnframes()):
00084             fout.writeframes(f.readframes(1))
00085         fout.close()
00086         self.assertLess(
00087             os.stat(TESTFN).st_size,
00088             os.stat(self.sndfilepath).st_size*0.75,
00089             )
00090         fout = self.fout = aifc.open(TESTFN, 'rb')
00091         f.rewind()
00092         self.assertEqual(f.getparams()[0:3], fout.getparams()[0:3])
00093         self.assertEqual(fout.getcomptype(), b'ULAW')
00094         self.assertEqual(fout.getcompname(), b'foo')
00095         # XXX: this test fails, not sure if it should succeed or not
00096         # self.assertEqual(f.readframes(5), fout.readframes(5))

Here is the call graph for this function:

Definition at line 32 of file test_aifc.py.

00032 
00033     def test_params(self):
00034         f = self.f = aifc.open(self.sndfilepath)
00035         self.assertEqual(f.getnchannels(), 2)
00036         self.assertEqual(f.getsampwidth(), 2)
00037         self.assertEqual(f.getframerate(), 48000)
00038         self.assertEqual(f.getnframes(), 14400)
00039         self.assertEqual(f.getcomptype(), b'NONE')
00040         self.assertEqual(f.getcompname(), b'not compressed')
00041         self.assertEqual(
00042             f.getparams(),
00043             (2, 2, 48000, 14400, b'NONE', b'not compressed'),
00044             )

Here is the call graph for this function:

Definition at line 45 of file test_aifc.py.

00045 
00046     def test_read(self):
00047         f = self.f = aifc.open(self.sndfilepath)
00048         self.assertEqual(f.tell(), 0)
00049         self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
00050         f.rewind()
00051         pos0 = f.tell()
00052         self.assertEqual(pos0, 0)
00053         self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
00054         pos2 = f.tell()
00055         self.assertEqual(pos2, 2)
00056         self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad')
00057         f.setpos(pos2)
00058         self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad')
00059         f.setpos(pos0)
00060         self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4')

Here is the call graph for this function:

Definition at line 27 of file test_aifc.py.

00027 
00028     def test_skipunknown(self):
00029         #Issue 2245
00030         #This file contains chunk types aifc doesn't recognize.
00031         self.f = aifc.open(self.sndfilepath)

Here is the call graph for this function:

Definition at line 61 of file test_aifc.py.

00061 
00062     def test_write(self):
00063         f = self.f = aifc.open(self.sndfilepath)
00064         fout = self.fout = aifc.open(TESTFN, 'wb')
00065         fout.aifc()
00066         fout.setparams(f.getparams())
00067         for frame in range(f.getnframes()):
00068             fout.writeframes(f.readframes(1))
00069         fout.close()
00070         fout = self.fout = aifc.open(TESTFN, 'rb')
00071         f.rewind()
00072         self.assertEqual(f.getparams(), fout.getparams())
00073         self.assertEqual(f.readframes(5), fout.readframes(5))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 101 of file test_aifc.py.

Definition at line 11 of file test_aifc.py.

Definition at line 100 of file test_aifc.py.

Definition at line 11 of file test_aifc.py.

Definition at line 12 of file test_aifc.py.


The documentation for this class was generated from the following file: