'get_image_dimensions() should catch struct.error while feeding the PIL
Image parser (#24544).
Emulates the Parser feed error. Since the error is raised on every feed
attempt, the resulting image size should be invalid: (None, None).'

def test_valid_image(self):

    img_path = os.path.join(os.path.dirname(__file__), 'test.png')
    with mock.patch('PIL.ImageFile.Parser.feed', side_effect=struct.error):
        with open(img_path, 'rb') as fh:
            size = images.get_image_dimensions(fh)
            self.assertEqual(size, (None, None))
