def testGoodFrame(self): # old-style self.assertEquals([good_frame_data], list(mp3.good_data(stringio(good_frame_data)))) l = list(mp3.good_data(stringio(good_frame_data + good_frame_data))) self.assertEquals(len(l), 2) self.assertEquals(l, [good_frame_data, good_frame_data]) # new-style self.assertEquals([good_frame_new], list(mp3.Reader(stringio(good_frame_data)).frames())) l = list( mp3.Reader(stringio(good_frame_data + good_frame_data)).frames()) self.assertEquals(len(l), 2) self.assertEquals(l, [good_frame_new, good_frame_new])
def testGoodID3v1Tag(self): # old-style f = stringio(good_id3v1_tag) self.assertEquals([good_id3v1_tag], list(mp3.good_data(f))) # new-style f.seek(0) self.assertEquals([good_id3v1_tag], list(mp3.Reader(f).frames(emit_meta_frames=True)))
def testRIFF(self): # old-style f = stringio(riff_frame) self.assertEquals([], list(mp3.good_data(f))) f = stringio(good_frame_data + riff_frame) self.assertEquals([good_frame_data], list(mp3.good_data(f))) f = stringio(riff_frame + good_frame_data) self.assertEquals([good_frame_data], list(mp3.good_data(f))) # new-style f = stringio(riff_frame) self.assertEquals([], list(mp3.Reader(f).frames(emit_riff_frames=False))) f = stringio(good_frame_data + riff_frame) self.assertEquals([good_frame_new], list(mp3.Reader(f).frames(emit_riff_frames=False))) f = stringio(riff_frame + good_frame_data) self.assertEquals([good_frame_new], list(mp3.Reader(f).frames(emit_riff_frames=False)))
def testGoodFrame(self): f = stringio(good_frame_data) # old-style l = list(mp3.frames(f)) self.assertEquals(len(l), 1) self.assertEquals(l, [(good_frame_header, good_frame_data)]) # new-style f.seek(0) r = mp3.Reader(f) l = list(r.frames()) self.assertEquals(len(l), 1) self.assertEquals(l, [good_frame_new])
def testSpuriousZeroes(self): self.assertEquals( [good_frame_data], list(mp3.good_data(stringio(good_frame_data + '\x00')))) self.assertEquals([good_frame_data, good_frame_data], list( mp3.good_data( stringio(good_frame_data + '\x00' + good_frame_data)))) self.assertEquals( [good_frame_data], list(mp3.good_data(stringio('\x00' + good_frame_data)))) self.assertEquals([good_frame_data, good_id3v1_tag], list( mp3.good_data( stringio('\x00' + good_frame_data + good_id3v1_tag)))) self.assertEquals([good_frame_data, good_id3v1_tag], list( mp3.good_data( stringio(good_frame_data + '\x00' + good_id3v1_tag)))) self.assertEquals([good_frame_data, good_id3v1_tag], list( mp3.good_data( stringio(good_frame_data + good_id3v1_tag + '\x00')))) # new-style self.assertEquals( [good_frame_new], list(mp3.Reader(stringio(good_frame_data + '\x00')).frames())) self.assertEquals([good_frame_new, good_frame_new], list( mp3.Reader( stringio(good_frame_data + '\x00' + good_frame_data)).frames())) self.assertEquals( [good_frame_new], list(mp3.Reader(stringio('\x00' + good_frame_data)).frames())) self.assertEquals([good_frame_new, good_id3v1_tag], list( mp3.Reader( stringio('\x00' + good_frame_data + good_id3v1_tag)).frames())) self.assertEquals([good_frame_new, good_id3v1_tag], list( mp3.Reader( stringio(good_frame_data + '\x00' + good_id3v1_tag)).frames())) self.assertEquals([good_frame_new, good_id3v1_tag], list( mp3.Reader( stringio(good_frame_data + good_id3v1_tag + '\x00')).frames()))