def test_generate_thumbnail_twice(self):
        image = self._image_with_thumbnail()
        old_path = image.thumbnail.path

        # The thumbnail exists.
        assert os.path.isfile(old_path)

        generate_thumbnail(image, 'file', 'thumbnail')
        new_path = image.thumbnail.path

        # The thumbnail was replaced.
        # Avoid potential failure when old thumbnail was saved 1 second ago.
        assert os.path.isfile(new_path)
        # Old file is either replaced or deleted.
        if old_path != new_path:
            assert not os.path.exists(old_path)
generate_thumbnail replaces old thumbnail.
dataset/ETHPy150Open mozilla/kitsune/kitsune/upload/tests/test_tasks.py/GenerateThumbnail.test_generate_thumbnail_twice