'Ensure that validation fails when the file extension does not match the
file data.'

def test_extension_mismatch(self):

    file_upload_bad_ext = u'The    file    name    extension    for    this    file    does    not    match    the    file    data.    The    file    may    be    corrupted.'
    with make_image_file(extension='.bmp') as bmp_file:
        with closing(NamedTemporaryFile(suffix='.jpeg')) as fake_jpeg_file:
            fake_jpeg_file.write(bmp_file.read())
            fake_jpeg_file.seek(0)
            uploaded_file = UploadedFile(fake_jpeg_file, content_type='image/jpeg', size=os.path.getsize(fake_jpeg_file.name))
            with self.assertRaises(ImageValidationError) as ctx:
                validate_uploaded_image(uploaded_file)
            self.assertEqual(ctx.exception.message, file_upload_bad_ext)
