code: def test_rasterize_pdf_errors(resources, no_outpdf, caplog):
      with patch("ocrmypdf._exec.ghostscript.run") as mock:
          # ghostscript can produce
          mock.return_value = subprocess.CompletedProcess(
              ["fakegs"],
              returncode=0,
              stdout=b"",
              stderr=b"error this is an error",
          )
          with pytest.raises(UnidentifiedImageError):
              rasterize_pdf(
                  resources / "francais.pdf",
                  no_outpdf,
                  raster_device="pngmono",
                  raster_dpi=Resolution(100, 100),
              )
          assert "this is an error" in caplog.text
          assert "invalid page image file" in caplog.text
  
imports: from __future__ import annotations
  import logging
  import secrets
  import subprocess
  from decimal import Decimal
  from unittest.mock import patch
  import pikepdf
  import pytest
  from PIL import Image, UnidentifiedImageError
  from ocrmypdf._exec.ghostscript import DuplicateFilter, rasterize_pdf
  from ocrmypdf.exceptions import ColorConversionNeededError, ExitCode
  from ocrmypdf.helpers import Resolution
  from .conftest import check_ocrmypdf, run_ocrmypdf_api
label_desc: Use image node_id 9 for calling a global function with example usage: test_rasterize_pdf_errors(resources, no_outpdf, caplog) without return types