def test_nonexisting_directory(self):
        """
        Test saving the file to a non existing directory.

        """
        song = Song(testfile)
        with self.assertRaises(FileNotFoundError):
            song.save('non/existing/directory/out.flac')
    def test_no_filename(self, filename):
        """
        Test saving metadata to the original input file.

        """
        shutil.copy(testfile, filename)
        song = Song(filename)
        song['track'] = 5
        song.save()
        new = Song(filename)
        self.assertEqual(new['track'], '5')
    def test_with_filename_and_changed_metadata(self, filename):
        """
        Test saving the file to a different location when different
        metadata has been set.

        """
        song = Song(testfile)
        song['artist'] = 'MaSu'
        song.save(filename=filename)
        copy = Song(filename)
        self.assertEqual(copy['artist'], 'MaSu')
    def test_with_filename(self, filename):
        """
        Test saving the file to a different location.

        """
        song = Song(testfile)
        song.save(filename=filename)
        copy = Song(filename)
        for tag in song:
            self.assertIn(tag, copy)
            self.assertEqual(song[tag], copy[tag])
        os.remove('out_unchanged.flac')
    def test_duplicate_init_call(self):
        """
        Test calling __init__ of an already initialized Song object
        raises a UserWarning.

        """
        song = Song(testfile)
        with self.assertRaises(UserWarning):
            song.__init__('f' * 200)
        with self.assertRaises(UserWarning):
            song.__init__(os.path.dirname(__import__(__name__).__file__))
        with self.assertRaises(UserWarning):
            song.__init__(testfile)
 def test_playback(self):
     song = Song(testfile)
     self.assertIsNone(song.play())