MCPcopy Index your code
hub / github.com/python/cpython / test_read

Method test_read

Lib/test/audiotests.py:282–304  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

280 fout.close() # do nothing
281
282 def test_read(self):
283 framesize = self.nchannels * self.sampwidth
284 chunk1 = self.frames[:2 * framesize]
285 chunk2 = self.frames[2 * framesize: 4 * framesize]
286 f = self.f = self.module.open(self.sndfilepath)
287 self.assertEqual(f.readframes(0), b'')
288 self.assertEqual(f.tell(), 0)
289 self.assertEqual(f.readframes(2), chunk1)
290 f.rewind()
291 pos0 = f.tell()
292 self.assertEqual(pos0, 0)
293 self.assertEqual(f.readframes(2), chunk1)
294 pos2 = f.tell()
295 self.assertEqual(pos2, 2)
296 self.assertEqual(f.readframes(2), chunk2)
297 f.setpos(pos2)
298 self.assertEqual(f.readframes(2), chunk2)
299 f.setpos(pos0)
300 self.assertEqual(f.readframes(2), chunk1)
301 with self.assertRaises(self.module.Error):
302 f.setpos(-1)
303 with self.assertRaises(self.module.Error):
304 f.setpos(f.getnframes() + 1)
305
306 def test_copy(self):
307 if self.readonly:

Callers

nothing calls this directly

Calls 8

readframesMethod · 0.80
openMethod · 0.45
assertEqualMethod · 0.45
tellMethod · 0.45
rewindMethod · 0.45
setposMethod · 0.45
assertRaisesMethod · 0.45
getnframesMethod · 0.45

Tested by

no test coverage detected