示例#1
0
class TAIFF(TestCase):
    silence_1 = os.path.join(DATA_DIR, '11k-1ch-2s-silence.aif')
    silence_2 = os.path.join(DATA_DIR, '48k-2ch-s16-silence.aif')
    silence_3 = os.path.join(DATA_DIR, '8k-1ch-1s-silence.aif')
    silence_4 = os.path.join(DATA_DIR, '8k-1ch-3.5s-silence.aif')
    silence_5 = os.path.join(DATA_DIR, '8k-4ch-1s-silence.aif')

    has_tags = os.path.join(DATA_DIR, 'with-id3.aif')
    no_tags = os.path.join(DATA_DIR, '8k-1ch-1s-silence.aif')

    def setUp(self):
        self.filename_1 = get_temp_copy(self.has_tags)
        self.filename_2 = get_temp_copy(self.no_tags)

        self.aiff_tmp_id3 = AIFF(self.filename_1)
        self.aiff_tmp_no_id3 = AIFF(self.filename_2)

        self.aiff_1 = AIFF(self.silence_1)
        self.aiff_2 = AIFF(self.silence_2)
        self.aiff_3 = AIFF(self.silence_3)
        self.aiff_4 = AIFF(self.silence_4)
        self.aiff_5 = AIFF(self.silence_5)

    def test_channels(self):
        self.failUnlessEqual(self.aiff_1.info.channels, 1)
        self.failUnlessEqual(self.aiff_2.info.channels, 2)
        self.failUnlessEqual(self.aiff_3.info.channels, 1)
        self.failUnlessEqual(self.aiff_4.info.channels, 1)
        self.failUnlessEqual(self.aiff_5.info.channels, 4)

    def test_length(self):
        self.failUnlessEqual(self.aiff_1.info.length, 2)
        self.failUnlessEqual(self.aiff_2.info.length, 0.1)
        self.failUnlessEqual(self.aiff_3.info.length, 1)
        self.failUnlessEqual(self.aiff_4.info.length, 3.5)
        self.failUnlessEqual(self.aiff_5.info.length, 1)

    def test_bitrate(self):
        self.failUnlessEqual(self.aiff_1.info.bitrate, 176400)
        self.failUnlessEqual(self.aiff_2.info.bitrate, 1536000)
        self.failUnlessEqual(self.aiff_3.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_4.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_5.info.bitrate, 512000)

    def test_sample_rate(self):
        self.failUnlessEqual(self.aiff_1.info.sample_rate, 11025)
        self.failUnlessEqual(self.aiff_2.info.sample_rate, 48000)
        self.failUnlessEqual(self.aiff_3.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_4.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_5.info.sample_rate, 8000)

    def test_bits_per_sample(self):
        self.failUnlessEqual(self.aiff_1.info.bits_per_sample, 16)
        self.failUnlessEqual(self.aiff_2.info.bits_per_sample, 16)
        self.failUnlessEqual(self.aiff_3.info.bits_per_sample, 16)
        self.failUnlessEqual(self.aiff_4.info.bits_per_sample, 16)
        self.failUnlessEqual(self.aiff_5.info.bits_per_sample, 16)

    def test_sample_size(self):
        for test in [
                self.aiff_1, self.aiff_2, self.aiff_3, self.aiff_4, self.aiff_5
        ]:
            info = test.info
            self.failUnlessEqual(info.sample_size, info.bits_per_sample)

    def test_notaiff(self):
        self.failUnlessRaises(AIFFError, AIFF,
                              os.path.join(DATA_DIR, 'empty.ofr'))

    def test_pprint(self):
        self.failUnless(self.aiff_1.pprint())
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_delete(self):
        self.aiff_tmp_id3.delete()
        self.failIf(self.aiff_tmp_id3.tags)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_delete(self):
        delete(self.filename_1)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_double_delete(self):
        delete(self.filename_1)
        delete(self.filename_1)

    def test_pprint_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_save_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.aiff_tmp_id3.save()
        self.assertTrue(self.aiff_tmp_id3.tags is None)

    def test_add_tags_already_there(self):
        self.failUnless(self.aiff_tmp_id3.tags)
        self.failUnlessRaises(Exception, self.aiff_tmp_id3.add_tags)

    def test_mime(self):
        self.failUnless("audio/aiff" in self.aiff_1.mime)
        self.failUnless("audio/x-aiff" in self.aiff_1.mime)

    def test_loaded_tags(self):
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_roundtrip(self):
        self.failUnlessEqual(self.aiff_tmp_id3["TIT2"], ["AIFF title"])
        self.aiff_tmp_id3.save()
        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT2"], ["AIFF title"])

    def test_save_tags(self):
        from mutagen.id3 import TIT1
        tags = self.aiff_tmp_id3.tags
        tags.add(TIT1(encoding=3, text="foobar"))
        tags.save()

        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT1"], ["foobar"])

    def test_save_with_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_id3.save()
        self.failUnless(AIFF(self.filename_1)["TIT1"] == "foobar")
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_save_without_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_no_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_no_id3.save()
        self.failUnless(AIFF(self.filename_2)["TIT1"] == "foobar")

    def test_corrupt_tag(self):
        with open(self.filename_1, "r+b") as h:
            chunk = IFFFile(h)[u'ID3']
            h.seek(chunk.data_offset)
            h.seek(4, 1)
            h.write(b"\xff\xff")
        self.assertRaises(AIFFError, AIFF, self.filename_1)

    def test_padding(self):
        AIFF(self.filename_1).save()
        self.assertEqual(AIFF(self.filename_1).tags._padding, 1002)
        AIFF(self.filename_1).save()
        self.assertEqual(AIFF(self.filename_1).tags._padding, 1002)

        tags = AIFF(self.filename_1)
        tags.save(padding=lambda x: 1)
        self.assertEqual(AIFF(self.filename_1).tags._padding, 1)

        tags = AIFF(self.filename_1)
        tags.save(padding=lambda x: 100)
        self.assertEqual(AIFF(self.filename_1).tags._padding, 100)

        tags = AIFF(self.filename_1)
        self.assertRaises(AIFFError, tags.save, padding=lambda x: -1)

    def tearDown(self):
        os.unlink(self.filename_1)
        os.unlink(self.filename_2)
示例#2
0
class TAIFF(TestCase):
    silence_1 = os.path.join('tests', 'data', '11k-1ch-2s-silence.aif')
    silence_2 = os.path.join('tests', 'data', '48k-2ch-s16-silence.aif')
    silence_3 = os.path.join('tests', 'data', '8k-1ch-1s-silence.aif')
    silence_4 = os.path.join('tests', 'data', '8k-1ch-3.5s-silence.aif')
    silence_5 = os.path.join('tests', 'data', '8k-4ch-1s-silence.aif')

    has_tags = os.path.join('tests', 'data', 'with-id3.aif')
    no_tags = os.path.join('tests', 'data', '8k-1ch-1s-silence.aif')

    def setUp(self):
        fd, self.filename_1 = mkstemp(suffix='.aif')
        os.close(fd)
        shutil.copy(self.has_tags, self.filename_1)

        fd, self.filename_2 = mkstemp(suffix='.aif')
        os.close(fd)
        shutil.copy(self.no_tags, self.filename_2)

        self.aiff_tmp_id3 = AIFF(self.filename_1)
        self.aiff_tmp_no_id3 = AIFF(self.filename_2)

        self.aiff_1 = AIFF(self.silence_1)
        self.aiff_2 = AIFF(self.silence_2)
        self.aiff_3 = AIFF(self.silence_3)
        self.aiff_4 = AIFF(self.silence_4)
        self.aiff_5 = AIFF(self.silence_5)

    def test_channels(self):
        self.failUnlessEqual(self.aiff_1.info.channels, 1)
        self.failUnlessEqual(self.aiff_2.info.channels, 2)
        self.failUnlessEqual(self.aiff_3.info.channels, 1)
        self.failUnlessEqual(self.aiff_4.info.channels, 1)
        self.failUnlessEqual(self.aiff_5.info.channels, 4)

    def test_length(self):
        self.failUnlessEqual(self.aiff_1.info.length, 2)
        self.failUnlessEqual(self.aiff_2.info.length, 0.1)
        self.failUnlessEqual(self.aiff_3.info.length, 1)
        self.failUnlessEqual(self.aiff_4.info.length, 3.5)
        self.failUnlessEqual(self.aiff_5.info.length, 1)

    def test_bitrate(self):
        self.failUnlessEqual(self.aiff_1.info.bitrate, 176400)
        self.failUnlessEqual(self.aiff_2.info.bitrate, 1536000)
        self.failUnlessEqual(self.aiff_3.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_4.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_5.info.bitrate, 512000)

    def test_sample_rate(self):
        self.failUnlessEqual(self.aiff_1.info.sample_rate, 11025)
        self.failUnlessEqual(self.aiff_2.info.sample_rate, 48000)
        self.failUnlessEqual(self.aiff_3.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_4.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_5.info.sample_rate, 8000)

    def test_sample_size(self):
        self.failUnlessEqual(self.aiff_1.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_2.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_3.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_4.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_5.info.sample_size, 16)

    def test_notaiff(self):
        self.failUnlessRaises(
            AIFFError, AIFF, os.path.join('tests', 'data', 'empty.ofr'))

    def test_pprint(self):
        self.failUnless(self.aiff_1.pprint())
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_delete(self):
        self.aiff_tmp_id3.delete()
        self.failIf(self.aiff_tmp_id3.tags)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_delete(self):
        delete(self.filename_1)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_double_delete(self):
        delete(self.filename_1)
        delete(self.filename_1)

    def test_pprint_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_save_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.failUnlessRaises(ValueError, self.aiff_tmp_id3.save)

    def test_add_tags_already_there(self):
        self.failUnless(self.aiff_tmp_id3.tags)
        self.failUnlessRaises(Exception, self.aiff_tmp_id3.add_tags)

    def test_mime(self):
        self.failUnless("audio/aiff" in self.aiff_1.mime)
        self.failUnless("audio/x-aiff" in self.aiff_1.mime)

    def test_loaded_tags(self):
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_roundtrip(self):
        self.failUnlessEqual(self.aiff_tmp_id3["TIT2"], ["AIFF title"])
        self.aiff_tmp_id3.save()
        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT2"], ["AIFF title"])

    def test_save_tags(self):
        from mutagen.id3 import TIT1
        tags = self.aiff_tmp_id3.tags
        tags.add(TIT1(encoding=3, text="foobar"))
        tags.save()

        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT1"], ["foobar"])

    def test_save_with_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_id3.save()
        self.failUnless(AIFF(self.filename_1)["TIT1"] == "foobar")
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_save_without_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_no_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_no_id3.save()
        self.failUnless(AIFF(self.filename_2)["TIT1"] == "foobar")

    def tearDown(self):
        os.unlink(self.filename_1)
        os.unlink(self.filename_2)
示例#3
0
class TAIFF(TestCase):
    silence_1 = os.path.join(DATA_DIR, '11k-1ch-2s-silence.aif')
    silence_2 = os.path.join(DATA_DIR, '48k-2ch-s16-silence.aif')
    silence_3 = os.path.join(DATA_DIR, '8k-1ch-1s-silence.aif')
    silence_4 = os.path.join(DATA_DIR, '8k-1ch-3.5s-silence.aif')
    silence_5 = os.path.join(DATA_DIR, '8k-4ch-1s-silence.aif')

    has_tags = os.path.join(DATA_DIR, 'with-id3.aif')
    no_tags = os.path.join(DATA_DIR, '8k-1ch-1s-silence.aif')

    def setUp(self):
        self.filename_1 = get_temp_copy(self.has_tags)
        self.filename_2 = get_temp_copy(self.no_tags)

        self.aiff_tmp_id3 = AIFF(self.filename_1)
        self.aiff_tmp_no_id3 = AIFF(self.filename_2)

        self.aiff_1 = AIFF(self.silence_1)
        self.aiff_2 = AIFF(self.silence_2)
        self.aiff_3 = AIFF(self.silence_3)
        self.aiff_4 = AIFF(self.silence_4)
        self.aiff_5 = AIFF(self.silence_5)

    def test_channels(self):
        self.failUnlessEqual(self.aiff_1.info.channels, 1)
        self.failUnlessEqual(self.aiff_2.info.channels, 2)
        self.failUnlessEqual(self.aiff_3.info.channels, 1)
        self.failUnlessEqual(self.aiff_4.info.channels, 1)
        self.failUnlessEqual(self.aiff_5.info.channels, 4)

    def test_length(self):
        self.failUnlessEqual(self.aiff_1.info.length, 2)
        self.failUnlessEqual(self.aiff_2.info.length, 0.1)
        self.failUnlessEqual(self.aiff_3.info.length, 1)
        self.failUnlessEqual(self.aiff_4.info.length, 3.5)
        self.failUnlessEqual(self.aiff_5.info.length, 1)

    def test_bitrate(self):
        self.failUnlessEqual(self.aiff_1.info.bitrate, 176400)
        self.failUnlessEqual(self.aiff_2.info.bitrate, 1536000)
        self.failUnlessEqual(self.aiff_3.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_4.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_5.info.bitrate, 512000)

    def test_sample_rate(self):
        self.failUnlessEqual(self.aiff_1.info.sample_rate, 11025)
        self.failUnlessEqual(self.aiff_2.info.sample_rate, 48000)
        self.failUnlessEqual(self.aiff_3.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_4.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_5.info.sample_rate, 8000)

    def test_sample_size(self):
        self.failUnlessEqual(self.aiff_1.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_2.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_3.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_4.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_5.info.sample_size, 16)

    def test_notaiff(self):
        self.failUnlessRaises(
            AIFFError, AIFF, os.path.join(DATA_DIR, 'empty.ofr'))

    def test_pprint(self):
        self.failUnless(self.aiff_1.pprint())
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_delete(self):
        self.aiff_tmp_id3.delete()
        self.failIf(self.aiff_tmp_id3.tags)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_delete(self):
        delete(self.filename_1)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_double_delete(self):
        delete(self.filename_1)
        delete(self.filename_1)

    def test_pprint_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_save_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.aiff_tmp_id3.save()
        self.assertTrue(self.aiff_tmp_id3.tags is None)

    def test_add_tags_already_there(self):
        self.failUnless(self.aiff_tmp_id3.tags)
        self.failUnlessRaises(Exception, self.aiff_tmp_id3.add_tags)

    def test_mime(self):
        self.failUnless("audio/aiff" in self.aiff_1.mime)
        self.failUnless("audio/x-aiff" in self.aiff_1.mime)

    def test_loaded_tags(self):
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_roundtrip(self):
        self.failUnlessEqual(self.aiff_tmp_id3["TIT2"], ["AIFF title"])
        self.aiff_tmp_id3.save()
        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT2"], ["AIFF title"])

    def test_save_tags(self):
        from mutagen.id3 import TIT1
        tags = self.aiff_tmp_id3.tags
        tags.add(TIT1(encoding=3, text="foobar"))
        tags.save()

        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT1"], ["foobar"])

    def test_save_with_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_id3.save()
        self.failUnless(AIFF(self.filename_1)["TIT1"] == "foobar")
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_save_without_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_no_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_no_id3.save()
        self.failUnless(AIFF(self.filename_2)["TIT1"] == "foobar")

    def test_corrupt_tag(self):
        with open(self.filename_1, "r+b") as h:
            chunk = IFFFile(h)[u'ID3']
            h.seek(chunk.data_offset)
            h.seek(4, 1)
            h.write(b"\xff\xff")
        self.assertRaises(AIFFError, AIFF, self.filename_1)

    def test_padding(self):
        AIFF(self.filename_1).save()
        self.assertEqual(AIFF(self.filename_1).tags._padding, 1002)
        AIFF(self.filename_1).save()
        self.assertEqual(AIFF(self.filename_1).tags._padding, 1002)

        tags = AIFF(self.filename_1)
        tags.save(padding=lambda x: 1)
        self.assertEqual(AIFF(self.filename_1).tags._padding, 1)

        tags = AIFF(self.filename_1)
        tags.save(padding=lambda x: 100)
        self.assertEqual(AIFF(self.filename_1).tags._padding, 100)

        tags = AIFF(self.filename_1)
        self.assertRaises(AIFFError, tags.save, padding=lambda x: -1)

    def tearDown(self):
        os.unlink(self.filename_1)
        os.unlink(self.filename_2)
示例#4
0
class TAIFF(TestCase):
    silence_1 = os.path.join('tests', 'data', '11k-1ch-2s-silence.aif')
    silence_2 = os.path.join('tests', 'data', '48k-2ch-s16-silence.aif')
    silence_3 = os.path.join('tests', 'data', '8k-1ch-1s-silence.aif')
    silence_4 = os.path.join('tests', 'data', '8k-1ch-3.5s-silence.aif')
    silence_5 = os.path.join('tests', 'data', '8k-4ch-1s-silence.aif')

    has_tags = os.path.join('tests', 'data', 'with-id3.aif')
    no_tags = os.path.join('tests', 'data', '8k-1ch-1s-silence.aif')

    def setUp(self):
        fd, self.filename_1 = mkstemp(suffix='.aif')
        os.close(fd)
        shutil.copy(self.has_tags, self.filename_1)

        fd, self.filename_2 = mkstemp(suffix='.aif')
        os.close(fd)
        shutil.copy(self.no_tags, self.filename_2)

        self.aiff_tmp_id3 = AIFF(self.filename_1)
        self.aiff_tmp_no_id3 = AIFF(self.filename_2)

        self.aiff_1 = AIFF(self.silence_1)
        self.aiff_2 = AIFF(self.silence_2)
        self.aiff_3 = AIFF(self.silence_3)
        self.aiff_4 = AIFF(self.silence_4)
        self.aiff_5 = AIFF(self.silence_5)

    def test_channels(self):
        self.failUnlessEqual(self.aiff_1.info.channels, 1)
        self.failUnlessEqual(self.aiff_2.info.channels, 2)
        self.failUnlessEqual(self.aiff_3.info.channels, 1)
        self.failUnlessEqual(self.aiff_4.info.channels, 1)
        self.failUnlessEqual(self.aiff_5.info.channels, 4)

    def test_length(self):
        self.failUnlessEqual(self.aiff_1.info.length, 2)
        self.failUnlessEqual(self.aiff_2.info.length, 0.1)
        self.failUnlessEqual(self.aiff_3.info.length, 1)
        self.failUnlessEqual(self.aiff_4.info.length, 3.5)
        self.failUnlessEqual(self.aiff_5.info.length, 1)

    def test_bitrate(self):
        self.failUnlessEqual(self.aiff_1.info.bitrate, 176400)
        self.failUnlessEqual(self.aiff_2.info.bitrate, 1536000)
        self.failUnlessEqual(self.aiff_3.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_4.info.bitrate, 128000)
        self.failUnlessEqual(self.aiff_5.info.bitrate, 512000)

    def test_sample_rate(self):
        self.failUnlessEqual(self.aiff_1.info.sample_rate, 11025)
        self.failUnlessEqual(self.aiff_2.info.sample_rate, 48000)
        self.failUnlessEqual(self.aiff_3.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_4.info.sample_rate, 8000)
        self.failUnlessEqual(self.aiff_5.info.sample_rate, 8000)

    def test_sample_size(self):
        self.failUnlessEqual(self.aiff_1.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_2.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_3.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_4.info.sample_size, 16)
        self.failUnlessEqual(self.aiff_5.info.sample_size, 16)

    def test_notaiff(self):
        self.failUnlessRaises(AIFFError, AIFF,
                              os.path.join('tests', 'data', 'empty.ofr'))

    def test_pprint(self):
        self.failUnless(self.aiff_1.pprint())
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_delete(self):
        self.aiff_tmp_id3.delete()
        self.failIf(self.aiff_tmp_id3.tags)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_delete(self):
        delete(self.filename_1)
        self.failUnless(AIFF(self.filename_1).tags is None)

    def test_module_double_delete(self):
        delete(self.filename_1)
        delete(self.filename_1)

    def test_pprint_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.failUnless(self.aiff_tmp_id3.pprint())

    def test_save_no_tags(self):
        self.aiff_tmp_id3.tags = None
        self.failUnlessRaises(ValueError, self.aiff_tmp_id3.save)

    def test_add_tags_already_there(self):
        self.failUnless(self.aiff_tmp_id3.tags)
        self.failUnlessRaises(Exception, self.aiff_tmp_id3.add_tags)

    def test_mime(self):
        self.failUnless("audio/aiff" in self.aiff_1.mime)
        self.failUnless("audio/x-aiff" in self.aiff_1.mime)

    def test_loaded_tags(self):
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_roundtrip(self):
        self.failUnlessEqual(self.aiff_tmp_id3["TIT2"], ["AIFF title"])
        self.aiff_tmp_id3.save()
        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT2"], ["AIFF title"])

    def test_save_tags(self):
        from mutagen.id3 import TIT1
        tags = self.aiff_tmp_id3.tags
        tags.add(TIT1(encoding=3, text="foobar"))
        tags.save()

        new = AIFF(self.aiff_tmp_id3.filename)
        self.failUnlessEqual(new["TIT1"], ["foobar"])

    def test_save_with_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_id3.save()
        self.failUnless(AIFF(self.filename_1)["TIT1"] == "foobar")
        self.failUnless(self.aiff_tmp_id3["TIT2"] == "AIFF title")

    def test_save_without_ID3_chunk(self):
        from mutagen.id3 import TIT1
        self.aiff_tmp_no_id3["TIT1"] = TIT1(encoding=3, text="foobar")
        self.aiff_tmp_no_id3.save()
        self.failUnless(AIFF(self.filename_2)["TIT1"] == "foobar")

    def tearDown(self):
        os.unlink(self.filename_1)
        os.unlink(self.filename_2)