code: def test_pdf_open(tmp_path):
      # fail on a buffer full of null bytes
      with pytest.raises(PdfParser.PdfFormatError):
          PdfParser.PdfParser(buf=bytearray(65536))
  
      # make an empty PDF object
      with PdfParser.PdfParser() as empty_pdf:
          assert len(empty_pdf.pages) == 0
          assert len(empty_pdf.info) == 0
          assert not empty_pdf.should_close_buf
          assert not empty_pdf.should_close_file
  
      # make a PDF file
      pdf_filename = helper_save_as_pdf(tmp_path, "RGB")
  
      # open the PDF file
      with PdfParser.PdfParser(filename=pdf_filename) as hopper_pdf:
          assert len(hopper_pdf.pages) == 1
          assert hopper_pdf.should_close_buf
          assert hopper_pdf.should_close_file
  
      # read a PDF file from a buffer with a non-zero offset
      with open(pdf_filename, "rb") as f:
          content = b"xyzzy" + f.read()
      with PdfParser.PdfParser(
          buf=content, start_offset=5
      ) as hopper_pdf:
          assert len(hopper_pdf.pages) == 1
          assert not hopper_pdf.should_close_buf
          assert not hopper_pdf.should_close_file
  
      # read a PDF file from an already open file
      with open(pdf_filename, "rb") as f:
          with PdfParser.PdfParser(f=f) as hopper_pdf:
              assert len(hopper_pdf.pages) == 1
              assert hopper_pdf.should_close_buf
              assert not hopper_pdf.should_close_file
  
imports: from __future__ import annotations
  import io
  import os
  import os.path
  import tempfile
  import time
  import pytest
  from PIL import Image, PdfParser, features
  from .helper import hopper, mark_if_feature_version, skip_unless_feature
label_desc: Use image node_id 11 for calling a global function with example usage: test_pdf_open(tmp_path) without return types