def test_to_dump_unicode(self): b = AudioFile(bar_1_1) b[u"öäü"] = u"öäü" dump = b.to_dump() n = AudioFile() n.from_dump(dump) self.assertEqual(n[u"öäü"], u"öäü")
def test_to_dump_long(self): b = AudioFile(bar_1_1) b["~#length"] = 200000000000L dump = b.to_dump() num = len(set(bar_1_1.keys()) | INTERN_NUM_DEFAULT) self.failUnlessEqual(dump.count("\n"), num + 2) n = AudioFile() n.from_dump(dump) self.failUnless(set(dump.split("\n")) == set(n.to_dump().split("\n")))
def test_to_dump_long(self): if not PY2: return b = AudioFile(bar_1_1) b["~#length"] = long(200000000000) dump = b.to_dump() num = len(set(bar_1_1.keys()) | NUMERIC_ZERO_DEFAULT) self.failUnlessEqual(dump.count("\n"), num + 2) n = AudioFile() n.from_dump(dump) self.failUnless(set(dump.split("\n")) == set(n.to_dump().split("\n")))
def test_to_dump(self): dump = bar_1_1.to_dump() num = len(set(bar_1_1.keys()) | INTERN_NUM_DEFAULT) self.failUnlessEqual(dump.count("\n"), num + 2) for key, value in bar_1_1.items(): self.failUnless(key in dump) self.failUnless(value in dump) for key in INTERN_NUM_DEFAULT: self.failUnless(key in dump) n = AudioFile() n.from_dump(dump) self.failUnless(set(dump.split("\n")) == set(n.to_dump().split("\n")))
def test_to_dump(self): dump = bar_1_1.to_dump() num = len(set(bar_1_1.keys()) | NUMERIC_ZERO_DEFAULT) self.failUnlessEqual(dump.count("\n"), num + 2) for key, value in bar_1_1.items(): self.failUnless(key in dump) self.failUnless(value in dump) for key in NUMERIC_ZERO_DEFAULT: self.failUnless(key in dump) n = AudioFile() n.from_dump(dump) self.failUnless(set(dump.split("\n")) == set(n.to_dump().split("\n")))
def test_to_dump(self): dump = bar_1_1.to_dump() num = len(set(bar_1_1.keys()) | NUMERIC_ZERO_DEFAULT) self.failUnlessEqual(dump.count(b"\n"), num + 2) for key, value in bar_1_1.items(): self.failUnless(key.encode("utf-8") in dump) self.failUnless(value.encode("utf-8") in dump) for key in NUMERIC_ZERO_DEFAULT: self.failUnless(key.encode("utf-8") in dump) n = AudioFile() n.from_dump(dump) self.failUnless( set(dump.split(b"\n")) == set(n.to_dump().split(b"\n")))
def test_dump_to_file(self): self.s["title"] = "artist - title" self.s.multisong = False dump = self.s.to_dump() new = AudioFile() new.from_dump(dump) self.assertEqual(new["title"], "title") self.assertEqual(new["artist"], "artist") del self.s["title"] dump = self.s.to_dump() new = AudioFile() new.from_dump(dump) self.assertTrue("title" not in new) self.assertTrue("artist" not in new)