code: def test_hocrtransform_matches_sandwich(resources, outdir):
      check_ocrmypdf(
          resources / "ccitt.pdf",
          outdir / "hocr.pdf",
          "--pdf-renderer=hocr",
      )
      check_ocrmypdf(
          resources / "ccitt.pdf",
          outdir / "tess.pdf",
          "--pdf-renderer=sandwich",
      )
  
      # Slight differences in spacing and word order can appear, so at least ensure
      # that we get all of the same words...
      def clean(s):
          s = re.sub(r"\s+", " ", s)
          words = s.split(" ")
          return "\n".join(sorted(words))
  
      hocr_txt = clean(text_from_pdf(outdir / "hocr.pdf"))
      tess_txt = clean(text_from_pdf(outdir / "tess.pdf"))
  
      # from pathlib import Path
      # Path('hocr.txt').write_text(hocr_txt)
      # Path('tess.txt').write_text(tess_txt)
  
      assert hocr_txt == tess_txt
  
file_path: OCRmyPDF/tests/test_hocrtransform.py
imports: from __future__ import annotations
  import re
  from io import StringIO
  import pytest
  from pdfminer.converter import TextConverter
  from pdfminer.layout import LAParams
  from pdfminer.pdfdocument import PDFDocument
  from pdfminer.pdfinterp import PDFPageInterpreter, PDFResourceManager
  from pdfminer.pdfpage import PDFPage
  from pdfminer.pdfparser import PDFParser
  from PIL import Image
  from ocrmypdf import hocrtransform
  from ocrmypdf._exec.tesseract import generate_hocr
  from ocrmypdf.helpers import check_pdf
  from .conftest import check_ocrmypdf
label_desc: Use image node_id 4 for calling a global function with example usage: test_hocrtransform_matches_sandwich(resources, outdir) and returns: str