def METHOD_NAME(
    self,
    image: Union[str, bytes],
    filename: str,
    entity_type: str,
    expected_error_substring: str
) -> None:
    """Checks that the image passes validation."""
    with self.assertRaisesRegex(
        utils.ValidationError, expected_error_substring):
        image_validation_services.validate_image_and_filename(
            image, filename, entity_type)