Back to index

python3.2  3.2.2
Public Member Functions
test.test_audioop.TestAudioop Class Reference

List of all members.

Public Member Functions

def test_max
def test_minmax
def test_maxpp
def test_avg
def test_avgpp
def test_rms
def test_cross
def test_add
def test_bias
def test_lin2lin
def test_adpcm2lin
def test_lin2adpcm
def test_lin2alaw
def test_alaw2lin
def test_lin2ulaw
def test_ulaw2lin
def test_mul
def test_ratecv
def test_reverse
def test_tomono
def test_tostereo
def test_findfactor
def test_findfit
def test_findmax
def test_getsample
def test_negativelen
def test_issue7673

Detailed Description

Definition at line 30 of file test_audioop.py.


Member Function Documentation

Definition at line 67 of file test_audioop.py.

00067 
00068     def test_add(self):
00069         data2 = []
00070         for d in data:
00071             str = bytearray(len(d))
00072             for i,b in enumerate(d):
00073                 str[i] = 2*b
00074             data2.append(str)
00075         self.assertEqual(audioop.add(data[0], data[0], 1), data2[0])
00076         self.assertEqual(audioop.add(data[1], data[1], 2), data2[1])
00077         self.assertEqual(audioop.add(data[2], data[2], 4), data2[2])

Here is the call graph for this function:

Definition at line 95 of file test_audioop.py.

00095 
00096     def test_adpcm2lin(self):
00097         # Very cursory test
00098         self.assertEqual(audioop.adpcm2lin(b'\0\0', 1, None), (b'\0\0\0\0', (0,0)))

Here is the call graph for this function:

Definition at line 108 of file test_audioop.py.

00108 
00109     def test_alaw2lin(self):
00110         # Cursory
00111         d = audioop.lin2alaw(data[0], 1)
00112         self.assertEqual(audioop.alaw2lin(d, 1), data[0])

Here is the call graph for this function:

Definition at line 47 of file test_audioop.py.

00047 
00048     def test_avg(self):
00049         self.assertEqual(audioop.avg(data[0], 1), 1)
00050         self.assertEqual(audioop.avg(data[1], 2), 1)
00051         self.assertEqual(audioop.avg(data[2], 4), 1)

Here is the call graph for this function:

Definition at line 52 of file test_audioop.py.

00052 
00053     def test_avgpp(self):
00054         self.assertEqual(audioop.avgpp(data[0], 1), 0)
00055         self.assertEqual(audioop.avgpp(data[1], 2), 0)
00056         self.assertEqual(audioop.avgpp(data[2], 4), 0)

Here is the call graph for this function:

Definition at line 78 of file test_audioop.py.

00078 
00079     def test_bias(self):
00080         # Note: this test assumes that avg() works
00081         d1 = audioop.bias(data[0], 1, 100)
00082         d2 = audioop.bias(data[1], 2, 100)
00083         d4 = audioop.bias(data[2], 4, 100)
00084         self.assertEqual(audioop.avg(d1, 1), 101)
00085         self.assertEqual(audioop.avg(d2, 2), 101)
00086         self.assertEqual(audioop.avg(d4, 4), 101)

Here is the call graph for this function:

Definition at line 62 of file test_audioop.py.

00062 
00063     def test_cross(self):
00064         self.assertEqual(audioop.cross(data[0], 1), 0)
00065         self.assertEqual(audioop.cross(data[1], 2), 0)
00066         self.assertEqual(audioop.cross(data[2], 4), 0)

Here is the call graph for this function:

Definition at line 157 of file test_audioop.py.

00157 
00158     def test_findfactor(self):
00159         self.assertEqual(audioop.findfactor(data[1], data[1]), 1.0)

Here is the call graph for this function:

Definition at line 160 of file test_audioop.py.

00160 
00161     def test_findfit(self):
00162         self.assertEqual(audioop.findfit(data[1], data[1]), (0, 1.0))

Here is the call graph for this function:

Definition at line 163 of file test_audioop.py.

00163 
00164     def test_findmax(self):
00165         self.assertEqual(audioop.findmax(data[1], 1), 2)

Here is the call graph for this function:

Definition at line 166 of file test_audioop.py.

00166 
00167     def test_getsample(self):
00168         for i in range(3):
00169             self.assertEqual(audioop.getsample(data[0], 1, i), i)
00170             self.assertEqual(audioop.getsample(data[1], 2, i), i)
00171             self.assertEqual(audioop.getsample(data[2], 4, i), i)

Here is the call graph for this function:

Definition at line 177 of file test_audioop.py.

00177 
00178     def test_issue7673(self):
00179         state = None
00180         for data, size in INVALID_DATA:
00181             size2 = size
00182             self.assertRaises(audioop.error, audioop.getsample, data, size, 0)
00183             self.assertRaises(audioop.error, audioop.max, data, size)
00184             self.assertRaises(audioop.error, audioop.minmax, data, size)
00185             self.assertRaises(audioop.error, audioop.avg, data, size)
00186             self.assertRaises(audioop.error, audioop.rms, data, size)
00187             self.assertRaises(audioop.error, audioop.avgpp, data, size)
00188             self.assertRaises(audioop.error, audioop.maxpp, data, size)
00189             self.assertRaises(audioop.error, audioop.cross, data, size)
00190             self.assertRaises(audioop.error, audioop.mul, data, size, 1.0)
00191             self.assertRaises(audioop.error, audioop.tomono, data, size, 0.5, 0.5)
00192             self.assertRaises(audioop.error, audioop.tostereo, data, size, 0.5, 0.5)
00193             self.assertRaises(audioop.error, audioop.add, data, data, size)
00194             self.assertRaises(audioop.error, audioop.bias, data, size, 0)
00195             self.assertRaises(audioop.error, audioop.reverse, data, size)
00196             self.assertRaises(audioop.error, audioop.lin2lin, data, size, size2)
00197             self.assertRaises(audioop.error, audioop.ratecv, data, size, 1, 1, 1, state)
00198             self.assertRaises(audioop.error, audioop.lin2ulaw, data, size)
00199             self.assertRaises(audioop.error, audioop.ulaw2lin, data, size)
00200             self.assertRaises(audioop.error, audioop.lin2alaw, data, size)
00201             self.assertRaises(audioop.error, audioop.alaw2lin, data, size)
00202             self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, state)
00203             self.assertRaises(audioop.error, audioop.adpcm2lin, data, size, state)

Here is the call graph for this function:

Definition at line 99 of file test_audioop.py.

00099 
00100     def test_lin2adpcm(self):
00101         # Very cursory test
00102         self.assertEqual(audioop.lin2adpcm(b'\0\0\0\0', 1, None), (b'\0\0', (0,0)))

Here is the call graph for this function:

Definition at line 103 of file test_audioop.py.

00103 
00104     def test_lin2alaw(self):
00105         self.assertEqual(audioop.lin2alaw(data[0], 1), b'\xd5\xc5\xf5')
00106         self.assertEqual(audioop.lin2alaw(data[1], 2), b'\xd5\xd5\xd5')
00107         self.assertEqual(audioop.lin2alaw(data[2], 4), b'\xd5\xd5\xd5')

Here is the call graph for this function:

Definition at line 87 of file test_audioop.py.

00087 
00088     def test_lin2lin(self):
00089         # too simple: we test only the size
00090         for d1 in data:
00091             for d2 in data:
00092                 got = len(d1)//3
00093                 wtd = len(d2)//3
00094                 self.assertEqual(len(audioop.lin2lin(d1, got, wtd)), len(d2))

Here is the call graph for this function:

Definition at line 113 of file test_audioop.py.

00113 
00114     def test_lin2ulaw(self):
00115         self.assertEqual(audioop.lin2ulaw(data[0], 1), b'\xff\xe7\xdb')
00116         self.assertEqual(audioop.lin2ulaw(data[1], 2), b'\xff\xff\xff')
00117         self.assertEqual(audioop.lin2ulaw(data[2], 4), b'\xff\xff\xff')

Here is the call graph for this function:

Definition at line 32 of file test_audioop.py.

00032 
00033     def test_max(self):
00034         self.assertEqual(audioop.max(data[0], 1), 2)
00035         self.assertEqual(audioop.max(data[1], 2), 2)
00036         self.assertEqual(audioop.max(data[2], 4), 2)

Here is the call graph for this function:

Definition at line 42 of file test_audioop.py.

00042 
00043     def test_maxpp(self):
00044         self.assertEqual(audioop.maxpp(data[0], 1), 0)
00045         self.assertEqual(audioop.maxpp(data[1], 2), 0)
00046         self.assertEqual(audioop.maxpp(data[2], 4), 0)

Here is the call graph for this function:

Definition at line 37 of file test_audioop.py.

00037 
00038     def test_minmax(self):
00039         self.assertEqual(audioop.minmax(data[0], 1), (0, 2))
00040         self.assertEqual(audioop.minmax(data[1], 2), (0, 2))
00041         self.assertEqual(audioop.minmax(data[2], 4), (0, 2))

Here is the call graph for this function:

Definition at line 123 of file test_audioop.py.

00123 
00124     def test_mul(self):
00125         data2 = []
00126         for d in data:
00127             str = bytearray(len(d))
00128             for i,b in enumerate(d):
00129                 str[i] = 2*b
00130             data2.append(str)
00131         self.assertEqual(audioop.mul(data[0], 1, 2), data2[0])
00132         self.assertEqual(audioop.mul(data[1],2, 2), data2[1])
00133         self.assertEqual(audioop.mul(data[2], 4, 2), data2[2])

Here is the call graph for this function:

Definition at line 172 of file test_audioop.py.

00172 
00173     def test_negativelen(self):
00174         # from issue 3306, previously it segfaulted
00175         self.assertRaises(audioop.error,
00176             audioop.findmax, ''.join(chr(x) for x in range(256)), -2392392)

Here is the call graph for this function:

Definition at line 134 of file test_audioop.py.

00134 
00135     def test_ratecv(self):
00136         state = None
00137         d1, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state)
00138         d2, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state)
00139         self.assertEqual(d1 + d2, b'\000\000\001\001\002\001\000\000\001\001\002')

Here is the call graph for this function:

Definition at line 140 of file test_audioop.py.

00140 
00141     def test_reverse(self):
00142         self.assertEqual(audioop.reverse(data[0], 1), b'\2\1\0')

Here is the call graph for this function:

Definition at line 57 of file test_audioop.py.

00057 
00058     def test_rms(self):
00059         self.assertEqual(audioop.rms(data[0], 1), 1)
00060         self.assertEqual(audioop.rms(data[1], 2), 1)
00061         self.assertEqual(audioop.rms(data[2], 4), 1)

Here is the call graph for this function:

Definition at line 143 of file test_audioop.py.

00143 
00144     def test_tomono(self):
00145         data2 = bytearray()
00146         for d in data[0]:
00147             data2.append(d)
00148             data2.append(d)
00149         self.assertEqual(audioop.tomono(data2, 1, 0.5, 0.5), data[0])

Here is the call graph for this function:

Definition at line 150 of file test_audioop.py.

00150 
00151     def test_tostereo(self):
00152         data2 = bytearray()
00153         for d in data[0]:
00154             data2.append(d)
00155             data2.append(d)
00156         self.assertEqual(audioop.tostereo(data[0], 1, 1, 1), data2)

Here is the call graph for this function:

Definition at line 118 of file test_audioop.py.

00118 
00119     def test_ulaw2lin(self):
00120         # Cursory
00121         d = audioop.lin2ulaw(data[0], 1)
00122         self.assertEqual(audioop.ulaw2lin(d, 1), data[0])

Here is the call graph for this function:


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