def test_write(self): s = SynchronizedTextSpec('name') f = Frame() values = [(u"A", 100), (u"\xe4xy", 0), (u"", 42), (u"", 0)] # utf-16 f.encoding = 1 self.assertEqual( s.read(None, f, s.write(None, f, values)), (values, b"")) data = s.write(None, f, [(u"A", 100)]) if sys.byteorder == 'little': self.assertEquals( data, b"\xff\xfeA\x00\x00\x00\x00\x00\x00d") else: self.assertEquals( data, b"\xfe\xff\x00A\x00\x00\x00\x00\x00d") # utf-16be f.encoding = 2 self.assertEqual( s.read(None, f, s.write(None, f, values)), (values, b"")) self.assertEquals( s.write(None, f, [(u"A", 100)]), b"\x00A\x00\x00\x00\x00\x00d") # utf-8 f.encoding = 3 self.assertEqual( s.read(None, f, s.write(None, f, values)), (values, b"")) self.assertEquals( s.write(None, f, [(u"A", 100)]), b"A\x00\x00\x00\x00d")
def test_write(self): s = SynchronizedTextSpec('name') f = Frame() values = [(u"A", 100), (u"\xe4xy", 0), (u"", 42), (u"", 0)] # utf-16 f.encoding = 1 self.assertEqual(s.read(None, f, s.write(None, f, values)), (values, b"")) data = s.write(None, f, [(u"A", 100)]) self.assertEquals(data, b"\xff\xfeA\x00\x00\x00\x00\x00\x00d") # utf-16be f.encoding = 2 self.assertEqual(s.read(None, f, s.write(None, f, values)), (values, b"")) self.assertEquals(s.write(None, f, [(u"A", 100)]), b"\x00A\x00\x00\x00\x00\x00d") # utf-8 f.encoding = 3 self.assertEqual(s.read(None, f, s.write(None, f, values)), (values, b"")) self.assertEquals(s.write(None, f, [(u"A", 100)]), b"A\x00\x00\x00\x00d")
def test_read(self): s = EncodedTextSpec('name') f = Frame() f.encoding = 0 header = ID3Header() header.version = (2, 4, 0) self.assertEquals((u'abcd', b'fg'), s.read(header, f, b'abcd\x00fg'))
def test_read(self): s = TimeStampSpec('name') f = Frame() f.encoding = 0 self.assertEquals( (ID3TimeStamp('ab'), b'fg'), s.read(None, f, b'ab\x00fg')) self.assertEquals( (ID3TimeStamp('1234'), b''), s.read(None, f, b'1234\x00'))
def test_read(self): s = TimeStampSpec('name') f = Frame() f.encoding = 0 self.assertEquals((ID3TimeStamp('ab'), b'fg'), s.read(None, f, b'ab\x00fg')) self.assertEquals((ID3TimeStamp('1234'), b''), s.read(None, f, b'1234\x00'))
def test_read(self): s = TimeStampSpec('name') f = Frame() f.encoding = 0 header = ID3Header() header.version = (2, 4, 0) self.assertEquals((ID3TimeStamp('ab'), b'fg'), s.read(header, f, b'ab\x00fg')) self.assertEquals((ID3TimeStamp('1234'), b''), s.read(header, f, b'1234\x00'))
def test_read(self): s = TimeStampSpec('name') f = Frame() f.encoding = 0 header = ID3Header() header.version = (2, 4, 0) self.assertEquals( (ID3TimeStamp('ab'), b'fg'), s.read(header, f, b'ab\x00fg')) self.assertEquals( (ID3TimeStamp('1234'), b''), s.read(header, f, b'1234\x00'))
def test_write(self): s = EncodedTextSpec('name') f = Frame() f.encoding = 0 self.assertEquals(b'abcdefg\x00', s.write(None, f, u'abcdefg')) self.assertRaises(AttributeError, s.write, None, f, None)
def test_read(self): s = EncodedTextSpec('name') f = Frame() f.encoding = 0 self.assertEquals((u'abcd', b'fg'), s.read(None, f, b'abcd\x00fg'))
def test_write(self): s = TimeStampSpec('name') f = Frame() f.encoding = 0 self.assertEquals(b'1234\x00', s.write(None, f, ID3TimeStamp('1234'))) self.assertRaises(AttributeError, s.write, None, f, None)