pytest_pyvista.VerifyImageCache#
- class pytest_pyvista.VerifyImageCache(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)#
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_namestr
Name of test to save. It is used to define the name of image cache file.
- cache_dirstr
Directory for image cache comparisons.
- error_valuefloat, default: 500
Threshold value for determining if two images are not similar enough in a test.
- warning_valuefloat, default: 200
Threshold value to warn that two images are different but not enough to fail the test.
- var_error_valuefloat, default: 1000
Same as error_value but for high variance tests.
- var_warning_valuefloat, default 1000
Same as warning_value but for high variance tests.
- generated_image_dirstr, 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 toverif
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)
- __init__(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)#
Methods
__init__
(test_name, cache_dir, *[, ...])Attributes
add_missing_images
fail_extra_image_cache
ignore_image_cache
reset_image_cache
reset_only_failed