code: def test_scraper(tmpdir, monkeypatch, n_win, scraper_type):
      pytest.importorskip("sphinx_gallery")
      monkeypatch.setattr(pv, "BUILDING_GALLERY", True)
      pv.close_all()
      plotters = [pv.Plotter(off_screen=True) for _ in range(n_win)]
      plotter_gif = pv.Plotter()
  
      # Initialize scraper and check stable representation
      if scraper_type == "static":
          scraper = Scraper()
          assert repr(scraper) == "<Scraper object>"
      elif scraper_type == "dynamic":
          scraper = DynamicScraper()
          assert repr(scraper) == "<DynamicScraper object>"
      else:
          raise ValueError(f"Invalid scraper type: {scraper}")
  
      src_dir = str(tmpdir)
      out_dir = op.join(str(tmpdir), "_build", "html")
      img_fnames = [
          op.join(src_dir, "auto_examples", "images", f"sg_img_{n}.png")
          for n in range(n_win)
      ]
  
      # create and save GIF to tmpdir
      gif_path = op.abspath(tmpdir + "sg_img_0.gif")
      plotter_gif.open_gif(gif_path)
      plotter_gif.write_frame()
      plotter_gif.close()
  
      gallery_conf = {"src_dir": src_dir, "builder_name": "html"}
      target_file = op.join(src_dir, "auto_examples", "sg.py")
      block = ("empty_block", "", 0)
      block_vars = dict(
          image_path_iterator=iter(img_fnames),
          example_globals=dict(
              a=1, PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT=True
          ),
          target_file=target_file,
      )
  
      os.makedirs(op.dirname(img_fnames[0]))
      for img_fname in img_fnames:
          assert not os.path.isfile(img_fname)
  
      # add gif to list after checking other filenames are empty
      img_fnames.append(gif_path)
      os.makedirs(out_dir)
      scraper(block, block_vars, gallery_conf)
      for img_fname in img_fnames:
          assert os.path.isfile(img_fname)
      for plotter in plotters:
          plotter.close()
  
file_path: pyvista/tests/plotting/test_scraper.py
imports: import os
  import os.path
  from matplotlib.pyplot import imread
  import pytest
  import pyvista
  from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper, Scraper
label_desc: Use image node_id 2 for calling a global function with example usage: test_scraper(tmpdir, monkeypatch, n_win, scraper_type) without return types