def testMultipleStrings(self): for cls in (stagger.Tag23, stagger.Tag24): # Versions 2.3 and 2.4 have support for multiple values in text # frames. tag = cls() tag.padding_max = 0 tag[TIT2] = ("Foo", "Bar", "Baz") self.assertEqual(len(tag[TIT2].text), 3) data = tag.encode() dtag = stagger.decode_tag(data) self.assertEqual(len(dtag[TIT2].text), 3) self.assertEqual(dtag[TIT2].text, tag[TIT2].text) # Version 2.2 has no such support, so stagger merges multiple strings. tag = stagger.Tag22() tag.padding_max = 0 tag[TT2] = ("Foo", "Bar", "Baz") self.assertEqual(len(tag[TT2].text), 3) with warnings.catch_warnings(record=True) as ws: data = tag.encode() self.assertEqual(len(ws), 1) self.assertEqual(ws[0].category, stagger.FrameWarning) dtag = stagger.decode_tag(data) self.assertEqual(len(dtag[TT2].text), 1) self.assertEqual(dtag[TT2].text, ["Foo / Bar / Baz"])
def testTitle22(self): tag = stagger.Tag22() tag[TT2] = "Foobar" self.assertEqual(tag.title, "Foobar") tag[TT2] = ("Foo", "Bar") self.assertEqual(tag.title, "Foo / Bar") tag.title = "Baz" self.assertEqual(tag[TT2], TT2(text=["Baz"])) self.assertEqual(tag.title, "Baz") tag.title = "Quux / Xyzzy" self.assertEqual(tag[TT2], TT2(text=["Quux", "Xyzzy"])) self.assertEqual(tag.title, "Quux / Xyzzy")
def testPicture22(self): tag = stagger.Tag22() # Check empty self.assertEqual(tag.picture, "") # Set to empty tag.picture = "" self.assertEqual(tag.picture, "") self.assertTrue(PIC not in tag) tag.picture = os.path.join(os.path.dirname(__file__), "samples", "cover.jpg") self.assertEqual(tag[PIC][0].type, 0) self.assertEqual(tag[PIC][0].desc, "") self.assertEqual(tag[PIC][0].format, "JPG") self.assertEqual(len(tag[PIC][0].data), 60511) self.assertEqual(tag.picture, "Other(0)::<60511 bytes of jpeg data>") # Set to empty tag.picture = "" self.assertEqual(tag.picture, "") self.assertTrue(PIC not in tag)