'Check that the created object is a JPEG and that it has the expected'

def check_exif_orientation(self, image, expected_orientation):

    self.assertEqual(image.format, 'JPEG')
    if (expected_orientation is not None):
        self.assertIn('exif', image.info)
        self.assertEqual(_get_exif_orientation(image.info['exif']), expected_orientation)
    else:
        self.assertIsNone(_get_exif_orientation(image.info.get('exif', piexif.dump({}))))
