def get_frame_data(name, size, bpi=True): data = name if bpi: data += BitPaddedInt.to_str(size) else: data += BitPaddedInt.to_str(size, bits=8) data += b"\x00\x00" + b"\x01" * size return data
def get_frame_data(name, size, bpi=True): data = name if bpi: data += BitPaddedInt.to_str(size) else: data += BitPaddedInt.to_str(size, bits=8) data += b"\x00\x00" + b"\x01" * size return data
def test_long(self): if PY2: data = BitPaddedInt.to_str(sys.maxint + 1, width=16) val = BitPaddedInt(data) self.assertEqual(val, sys.maxint + 1) self.assertTrue(isinstance(val, BitPaddedLong)) else: self.assertTrue(BitPaddedInt is BitPaddedLong)
def test_long(self): if PY2: data = BitPaddedInt.to_str(sys.maxint + 1, width=16) val = BitPaddedInt(data) self.assertEqual(val, sys.maxint + 1) self.assertTrue(isinstance(val, BitPaddedLong)) else: self.assertTrue(BitPaddedInt is BitPaddedLong)
def test_read__ignore_CRM(self): tags = ID3Tags() header = ID3Header() header.version = ID3Header._V22 framedata = CRM(owner="foo", desc="bar", data=b"bla")._writeData() datasize = BitPaddedInt.to_str(len(framedata), width=3, bits=8) tags._read(header, b"CRM" + datasize + framedata) self.assertEqual(len(tags), 0)
def test_read__ignore_CRM(self): tags = ID3Tags() header = ID3Header() header.version = ID3Header._V22 framedata = CRM(owner="foo", desc="bar", data=b"bla")._writeData() datasize = BitPaddedInt.to_str(len(framedata), width=3, bits=8) tags._read(header, b"CRM" + datasize + framedata) self.assertEqual(len(tags), 0)
def test_minwidth(self): self.assertEquals( len(BitPaddedInt.to_str(100, width=-1, minwidth=6)), 6)
def test_varwidth(self): self.assertEquals(len(BitPaddedInt.to_str(100)), 4) self.assertEquals(len(BitPaddedInt.to_str(100, width=-1)), 4) self.assertEquals(len(BitPaddedInt.to_str(2 ** 32, width=-1)), 5)
def test_w129l(self): self.assertEquals( BitPaddedInt.to_str(129, width=2, bigendian=False), b'\x01\x01')
def test_w129(self): self.assertEquals(BitPaddedInt.to_str(129, width=2), b'\x01\x01')
def test_s65(self): self.assertEquals(BitPaddedInt.to_str(0x41, 6), b'\x00\x00\x01\x01')
def test_s129(self): self.assertEquals(BitPaddedInt.to_str(129), b'\x00\x00\x01\x01')
def test_w129(self): self.assertEquals(BitPaddedInt.to_str(129, width=2), b'\x01\x01')
def test_s0(self): self.assertEquals(BitPaddedInt.to_str(0), b'\x00\x00\x00\x00')
def test_s0(self): self.assertEquals(BitPaddedInt.to_str(0), b'\x00\x00\x00\x00')
def test_s129(self): self.assertEquals(BitPaddedInt.to_str(129), b'\x00\x00\x01\x01')
def test_minwidth(self): self.assertEquals( len(BitPaddedInt.to_str(100, width=-1, minwidth=6)), 6)
def test_varwidth(self): self.assertEquals(len(BitPaddedInt.to_str(100)), 4) self.assertEquals(len(BitPaddedInt.to_str(100, width=-1)), 4) self.assertEquals(len(BitPaddedInt.to_str(2 ** 32, width=-1)), 5)
def test_w129l(self): self.assertEquals( BitPaddedInt.to_str(129, width=2, bigendian=False), b'\x01\x01')
def test_s1l(self): self.assertEquals( BitPaddedInt.to_str(1, bigendian=False), b'\x01\x00\x00\x00')
def test_s1l(self): self.assertEquals( BitPaddedInt.to_str(1, bigendian=False), b'\x01\x00\x00\x00')
def test_s65(self): self.assertEquals(BitPaddedInt.to_str(0x41, 6), b'\x00\x00\x01\x01')