class_docstr: Control image caching for testing.
  
  Image cache files are named according to ``test_name``.
  Multiple calls to an instance of this class will append
  `_X` to the name after the first one.  That is, files
  ``{test_name}``, ``{test_name}_1``, and ``{test_name}_2``
  will be saved if called 3 times.
  
  Parameters
  ----------
  test_name : str
      Name of test to save.  It is used to define the name of image cache
      file.
  
  cache_dir : str
      Directory for image cache comparisons.
  
  error_value : float, default: 500
      Threshold value for determining if two images are not similar enough in
      a test.
  
  warning_value : float, default: 200
      Threshold value to warn that two images are different but not enough to
      fail the test.
  
  var_error_value : float, default: 1000
      Same as error_value but for high variance tests.
  
  var_warning_value : float, default 1000
      Same as warning_value but for high variance tests.
  
  generated_image_dir : str, optional
      Directory to save generated images.  If not specified, no generated
      images are saved.
  
  Examples
  --------
  Create an image cache directory named image_cache and check a simple
  plotter against it. Since ``image_cache`` doesn't exist, it will be created
  and basic.png will be added to it. Subsequent calls to ``verif`` will
  compare the plotter against the cached image.
  
  >>> import pyvista as pv
  >>> from pytest_pyvista import VerifyImageCache
  >>> pl = pv.Plotter(off_screen=True)
  >>> pl.add_mesh(pv.Sphere())
  >>> verif = VerifyImageCache('test_basic', 'image_cache')
  >>> verif(pl)
code: def __init__(
      self,
      test_name,
      cache_dir,
      *,
      error_value=500.0,
      warning_value=200.0,
      var_error_value=1000.0,
      var_warning_value=1000.0,
      generated_image_dir=None,
  ):
      self.test_name = test_name
  
      self.cache_dir = cache_dir
  
      if not os.path.isdir(self.cache_dir):
          warnings.warn(
              f"pyvista test cache image dir: {self.cache_dir} does not yet exist'  Creating empty cache."
          )
          os.mkdir(self.cache_dir)
  
      self.error_value = error_value
      self.warning_value = warning_value
      self.var_error_value = var_error_value
      self.var_warning_value = var_warning_value
  
      self.generated_image_dir = generated_image_dir
      if self.generated_image_dir is not None and not os.path.isdir(
          self.generated_image_dir
      ):
          warnings.warn(
              f"pyvista test generated image dir: {self.generated_image_dir} does not yet exist.  Creating dir."
          )
          os.makedirs(self.generated_image_dir)
  
      self.high_variance_test = False
      self.windows_skip_image_cache = False
      self.macos_skip_image_cache = False
  
      self.skip = False
      self.n_calls = 0
  
file_path: pytest-pyvista/pytest_pyvista/pytest_pyvista.py
imports: import os
  import platform
  import warnings
  import pytest
  import pyvista
label_desc: Use image node_id 1 to create a new VerifyImageCache object  with example: obj = VerifyImageCache(test_name, cache_dir)