def test_python3_strict_str(self): comment = VComment() comment.append((u"abc", u"test")) comment.validate() comment[0] = (u"abc", b"test") self.failUnlessRaises(ValueError, comment.validate) comment[0] = (b"abc", u"test") self.failUnlessRaises(ValueError, comment.validate)
def test_empty_valid(self): self.failIf(VComment(b"\x00\x00\x00\x00" * 2 + b"\x01"))
def setUp(self): self.c = VComment() self.c.append(("artist", u"piman")) self.c.append(("artist", u"mu")) self.c.append(("title", u"more fakes"))
def test_roundtrip_vc(self): self.failUnlessEqual(self.c, VComment(self.c.write()))
def test_roundtrip(self): self.assertReallyEqual(self.c, VComment(self.c.write()))
def test_invalid_tag_ignore(self): data = (b'\x07\x00\x00\x00Mutagen\x01\x00\x00\x00\x04\x00\x00' b'\x00\xc2\xaa=c\x01') comment = VComment(data, errors='ignore') self.failIf(len(comment))
def test_invalid_tag_replace(self): data = (b'\x07\x00\x00\x00Mutagen\x01\x00\x00\x00\x04\x00\x00' b'\x00\xc2\xaa=c\x01') comment = VComment(data) self.failUnlessEqual(u"?=c", comment.pprint())
def test_invalid_format_ignore(self): data = (b'\x07\x00\x00\x00Mutagen\x01\x00\x00\x00\x03\x00\x00' b'\x00abc\x01') comment = VComment(data, errors='ignore') self.failIf(len(comment))
def test_python_key_value_type(self): data = (b'\x07\x00\x00\x00Mutagen\x01\x00\x00\x00\x03\x00\x00' b'\x00abc\x01') comment = VComment(data) self.assertTrue(isinstance(comment[0][0], type(''))) self.assertTrue(isinstance(comment[0][1], text_type))
def test_invalid_format_replace(self): data = (b'\x07\x00\x00\x00Mutagen\x01\x00\x00\x00\x03\x00\x00' b'\x00abc\x01') comment = VComment(data) self.failUnlessEqual(u"abc", comment[0][1])