Skip to main content

Plugin to test PyVista plot outputs

Project description

PyPI version Python versions See Build Status on AppVeyor

Plugin to test PyVista plot outputs.


This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

Features

This plugin facilitates the comparison of the images produced by PyVista. It generates a cache of images from the tests, using the PyVista plotting function in its first execution. Then, further executions will compare its results against this cache, so if there are any changes in the code that break the image generation, the comparison against the cache will notice it. Note that there is an error tolerance in the comparison, so minor differences won’t fail.

Requirements

You must have a Python version greater than 3.7, as well as PyVista installed in your environment.

Installation

You can install “pytest-pyvista” via pip from PyPI:

$ pip install pytest-pyvista

Usage

Once installed, you only need to use the command pl.show() in your test. The plugin will automatically manage the cache generation if it does not exist, and the image comparison itself. Make sure you enable pv.OFF_SCREEN when loading PyVista, so the pl.show() doesn’t pop up any window while testing:

import pyvista as pv
pv.OFF_SCREEN = True
def test_succeeds():
    pl = pyvista.Plotter()
    pl.add_mesh(pyvista.Sphere(), show_edges=True)
    pl.show()

If you need to use any flag inside the tests, you need to use the verify_image_cache fixture as a parameter to the test:

import pyvista as pv
pv.OFF_SCREEN = True
def test_succeeds(verify_image_cache):
    verify_image_cache.windows_skip_image_cache = True
    pl = pyvista.Plotter()
    pl.add_mesh(pyvista.Sphere(), show_edges=True)
    pl.show()

Global flags

These are the flags you can use when calling pytest in the command line:

  • --reset_image_cache creates a new image for each test in tests/plotting/test_plotting.py and is not recommended except for testing or for potentially a major or minor release.

  • You can use --ignore_image_cache if you are running on Linux and want to temporarily ignore regression testing. Realize that regression testing will still occur on our CI testing.

  • When using --fail_extra_image_cache if there is an extra image in the cache, it will report as an error.

Test specific flags

These are attributes of verify_image_cache. You can set them as True if needed in the beginning of your test function.

  • high_variance_tests: If necessary, the threshold for determining if a test will pass or not is incremented to another predetermined threshold. This is currently done due to the use of an unstable version of VTK, in stable versions this shouldn’t be necessary.

  • windows_skip_image_cache: For test where the plotting in Windows is different from MacOS/Linux.

  • macos_skip_image_cache: For test where the plotting in MacOS is different from Windows/Linux.

  • skip: If you have a test that plots a figure, but you don’t want to compare its output against the cache, you can skip it with this flag.

Contributing

Contributions are always welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, pytest-pyvista is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-pyvista-0.1.dev0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

pytest_pyvista-0.1.dev0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest-pyvista-0.1.dev0.tar.gz.

File metadata

  • Download URL: pytest-pyvista-0.1.dev0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.15

File hashes

Hashes for pytest-pyvista-0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 7d28fa79664a0c76b27ebdc3c17160defce85dead7b72dee4d5f36c916509c11
MD5 a9b69c5de8e19d332a14347b98497d27
BLAKE2b-256 10f32cdc86af944e8437b67a3cf6d1f2d13fc50110acf4511895dcdb7324c9db

See more details on using hashes here.

Provenance

File details

Details for the file pytest_pyvista-0.1.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_pyvista-0.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 c50d844d7cf0a10c7d2e92a5f4ef652beeb7e9024e0031de8988e8878899cab0
MD5 4d2c3b1778dc690765b38db51c2dcb23
BLAKE2b-256 91e16e6998b35292ac1ca487ca5ddb998e65f97c112c0d2adaf736390ad6d58b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page