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

Method test_ieee_float_has_fact_chunk

Lib/test/test_wave.py:344–373  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

342 self.assertIsNone(cm.unraisable)
343
344 def test_ieee_float_has_fact_chunk(self):
345 nframes = 100
346 with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
347 filename = fp.name
348 self.addCleanup(unlink, filename)
349
350 with wave.open(filename, 'wb') as w:
351 w.setnchannels(1)
352 w.setsampwidth(4)
353 w.setframerate(22050)
354 w.setformat(wave.WAVE_FORMAT_IEEE_FLOAT)
355 w.writeframes(b'\x00\x00\x00\x00' * nframes)
356
357 with open(filename, 'rb') as f:
358 f.read(12)
359 fact_found = False
360 fact_samples = None
361 while True:
362 chunk_id = f.read(4)
363 if len(chunk_id) < 4:
364 break
365 chunk_size = struct.unpack('<L', f.read(4))[0]
366 if chunk_id == b'fact':
367 fact_found = True
368 fact_samples = struct.unpack('<L', f.read(4))[0]
369 break
370 f.seek(chunk_size + (chunk_size & 1), 1)
371
372 self.assertTrue(fact_found)
373 self.assertEqual(fact_samples, nframes)
374
375 def test_pcm_has_no_fact_chunk(self):
376 with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:

Callers

nothing calls this directly

Calls 13

addCleanupMethod · 0.80
setnchannelsMethod · 0.80
setsampwidthMethod · 0.80
setframerateMethod · 0.80
setformatMethod · 0.80
writeframesMethod · 0.80
unpackMethod · 0.80
assertTrueMethod · 0.80
openFunction · 0.50
openMethod · 0.45
readMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected