Skip to content

Commit

Permalink
Release v0.1.9 (#89)
Browse files Browse the repository at this point in the history
* Support installation from Conda

* Remove vtk8 handling (#44)

* remove vtk8

* update readme

* remove from ci

* Align CI versions with pyvista CI

* Remove mention from documentation in readme

* Bump pydata-sphinx-theme from 0.12.0 to 0.13.1 (#48)

Bumps [pydata-sphinx-theme](https://github.com/pydata/pydata-sphinx-theme) from 0.12.0 to 0.13.1.
- [Release notes](https://github.com/pydata/pydata-sphinx-theme/releases)
- [Commits](pydata/pydata-sphinx-theme@v0.12.0...v0.13.1)

---
updated-dependencies:
- dependency-name: pydata-sphinx-theme
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump coverage from 7.0.5 to 7.2.1 (#45)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.0.5 to 7.2.1.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.0.5...7.2.1)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump coverage from 7.2.1 to 7.2.2 (#52)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.1 to 7.2.2.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.2.1...7.2.2)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add downstream tests and guard against leakages across tests (#49)

* Add downstream tests

* fix requirements install

* changes to working directory and software report

* narrow testing scope

* use dev version

* Temporarily use upstream branch

* Bug: guard against leaking verify_image_cache (#51)

* teardown fixture

* Fix teardown

* Teardown on errors

* update verbosity of tests temporarily

* Update ci_cd.yml

Partially remove verbosity

* use addfinalizer

* format

* use tmp branch

* Back to main branch

* Guard against leakages

* revert verbosity

* whitespace

* Update ci_cd.yml

use other branch

* Try latest python

* upload generated_images as artifact

* run upload on failure

* use same ubuntu version

* use main branch again

* Use main branch again

* add test

* Bump coverage from 7.2.2 to 7.2.3 (#57)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.2 to 7.2.3.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.2.2...7.2.3)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pydata-sphinx-theme from 0.13.1 to 0.13.3 (#56)

Bumps [pydata-sphinx-theme](https://github.com/pydata/pydata-sphinx-theme) from 0.13.1 to 0.13.3.
- [Release notes](https://github.com/pydata/pydata-sphinx-theme/releases)
- [Commits](pydata/pydata-sphinx-theme@v0.13.1...v0.13.3)

---
updated-dependencies:
- dependency-name: pydata-sphinx-theme
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sphinx-copybutton from 0.5.1 to 0.5.2 (#58)

Bumps [sphinx-copybutton](https://github.com/executablebooks/sphinx-copybutton) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/executablebooks/sphinx-copybutton/releases)
- [Changelog](https://github.com/executablebooks/sphinx-copybutton/blob/master/CHANGELOG.md)
- [Commits](executablebooks/sphinx-copybutton@v0.5.1...v0.5.2)

---
updated-dependencies:
- dependency-name: sphinx-copybutton
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump coverage from 7.2.3 to 7.2.5 (#59)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.3 to 7.2.5.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.2.3...7.2.5)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pytest-cov from 4.0.0 to 4.1.0 (#61)

Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 4.0.0 to 4.1.0.
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](pytest-dev/pytest-cov@v4.0.0...v4.1.0)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump coverage from 7.2.5 to 7.2.7 (#62)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.5 to 7.2.7.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.2.5...7.2.7)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update numpy requirement from <1.24 to <1.26 (#63)

* Update numpy requirement from <1.24 to <1.26

Updates the requirements on [numpy](https://github.com/numpy/numpy) to permit the latest version.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](numpy/numpy@v0.2.0...v1.25.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* pin numpy for older vtk

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* Fix CI; Remove python 3.7; remove flake8-isort (#66)

* remove python 3.7

* remove flake8-isort

* bump isort version

* pin sphinx (#67)

* [pre-commit.ci] pre-commit autoupdate (#64)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.10.0 → 23.7.0](psf/black@22.10.0...23.7.0)
- [github.com/pycqa/isort: 5.10.1 → 5.12.0](PyCQA/isort@5.10.1...5.12.0)
- [github.com/PyCQA/flake8: 5.0.4 → 6.1.0](PyCQA/flake8@5.0.4...6.1.0)
- [github.com/codespell-project/codespell: v2.2.2 → v2.2.5](codespell-project/codespell@v2.2.2...v2.2.5)
- [github.com/pycqa/pydocstyle: 6.1.1 → 6.3.0](PyCQA/pydocstyle@6.1.1...6.3.0)
- [github.com/pre-commit/mirrors-mypy: v0.982 → v1.5.1](pre-commit/mirrors-mypy@v0.982...v1.5.1)
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](pre-commit/pre-commit-hooks@v4.3.0...v4.4.0)
- [github.com/python-jsonschema/check-jsonschema: 0.18.4 → 0.24.1](python-jsonschema/check-jsonschema@0.18.4...0.24.1)

* mypy-extensions

* remove flake8-black

* Bump flake8-quotes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alex Kaszynski <akascap@gmail.com>
Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#70)

updates:
- [github.com/python-jsonschema/check-jsonschema: 0.24.1 → 0.26.3](python-jsonschema/check-jsonschema@0.24.1...0.26.3)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump sphinx-notfound-page from 0.8.3 to 1.0.0 (#71)

Bumps [sphinx-notfound-page](https://github.com/readthedocs/sphinx-notfound-page) from 0.8.3 to 1.0.0.
- [Changelog](https://github.com/readthedocs/sphinx-notfound-page/blob/main/CHANGELOG.rst)
- [Commits](readthedocs/sphinx-notfound-page@0.8.3...1.0.0)

---
updated-dependencies:
- dependency-name: sphinx-notfound-page
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sphinx from 7.1.2 to 7.2.5 (#72)

* Bump coverage from 7.2.7 to 7.3.1 (#74)

Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.7 to 7.3.1.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@7.2.7...7.3.1)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/checkout from 3 to 4 (#73)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#75)

updates:
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Bump sphinx from 7.2.5 to 7.2.6 (#76)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 7.2.5 to 7.2.6.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES)
- [Commits](sphinx-doc/sphinx@v7.2.5...v7.2.6)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Change dependency/CI version updates to monthly (#77)

* Change dependabot to monthly

* Update .pre-commit-config.yaml

* Bump codecov/codecov-action from 3 to 4 (#78)

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update LICENSE year (#81)

* Update LICENSE year

* Update ci_cd.yml

* Reset cache only if error (#82)

* Implementation

* Adding cli option

* Pre-commit fix

* feat: Add test for the new flag

* fix: Flag wasn't being captured

* fix: pre-commit issues

* fix: Remove print

* fix: Test image being overwritten

---------

Co-authored-by: afernand <alex.fernandezluces@ansys.com>

* Update README with conda/mamba install (#84)

* Update README with conda/mamba install

* Add conda-forge badge + icons

* Adding custom error class (#80)

* Adding custom error class

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Using codecov v3

* Removing init

* Reusing test to make sure the class is raised used. Adding test for file not found.

* Fixing test

* pre-commit fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Typo fix geovista to pytest-pyvista (#88)

* Ad info about new flag (#87)

Co-authored-by: German <germanmartinezayuso@gmail.com>

* Bump version

* pre-commit fix

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alex Kaszynski <akascap@gmail.com>
Co-authored-by: Tetsuo Koyama <tkoyama010@gmail.com>
Co-authored-by: German <28149841+germa89@users.noreply.github.com>
Co-authored-by: Bill Little <bill.little@metoffice.gov.uk>
Co-authored-by: German <germanmartinezayuso@gmail.com>
  • Loading branch information
9 people authored Sep 29, 2023
1 parent bb0fda6 commit 713eeb0
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ updates:
directory: "/" # Location of package manifests
insecure-external-code-execution: allow
schedule:
interval: "daily"
interval: "monthly"
labels:
- "maintenance"
- "dependencies"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"
labels:
- "maintenance"
- "dependencies"
- "dependencies"
14 changes: 8 additions & 6 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Build Documentation
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
Expand Down Expand Up @@ -59,8 +59,6 @@ jobs:

matrix:
include:
- python-version: '3.7'
vtk-version: '9.0.3'
- python-version: '3.8'
vtk-version: '9.0.3'
- python-version: '3.9'
Expand All @@ -70,7 +68,7 @@ jobs:
- python-version: '3.11'
vtk-version: 'latest'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -87,6 +85,10 @@ jobs:
if: ${{ matrix.vtk-version != 'latest' }}
run: pip install vtk==${{ matrix.vtk-version }}

- name: Limit NumPy for VTK 9.0.3
if: ${{ matrix.vtk-version == '9.0.3' }}
run: pip install 'numpy<1.24'

- uses: awalsh128/cache-apt-pkgs-action@v1.1.3
with:
packages: libgl1-mesa-glx xvfb python-tk
Expand All @@ -113,7 +115,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down Expand Up @@ -147,7 +149,7 @@ jobs:
name: Downstream tests
runs-on: ubuntu-20.04 # matching pyvista
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
Expand Down
26 changes: 14 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
ci:
autofix_prs: false
autoupdate_schedule: monthly

repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.9.1
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [
"flake8-black==0.3.3",
"flake8-isort==4.2.0",
"flake8-quotes==3.3.1",
"flake8-quotes==3.3.2",
]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.5
hooks:
- id: codespell
args: [
Expand All @@ -29,26 +31,26 @@ repos:
]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies: [toml==0.10.2]
files: ^(pytest-pyvista/|other/)
exclude: ^pytest-pyvista/ext/

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.5.1
hooks:
- id: mypy
exclude: ^(doc/|tests/|examples/|pytest-pyvista/ext/|examples_flask/)
additional_dependencies: [
"mypy-extensions==0.4.3",
"mypy-extensions==1.0.0",
"toml==0.10.2",
"typing-extensions==4.1.1",
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: debug-statements
Expand All @@ -58,6 +60,6 @@ repos:

# this validates our github workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.18.4
rev: 0.26.3
hooks:
- id: check-github-workflows
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2022 The PyVista Developers
Copyright (c) 2022-2023 The PyVista Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 15 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
==============
pytest-pyvista
==============
.. image:: https://img.shields.io/pypi/v/pytest-pyvista.svg
.. image:: https://img.shields.io/pypi/v/pytest-pyvista.svg?color=orange&label=pypi&logo=python&logoColor=white
:target: https://pypi.org/project/pytest-pyvista
:alt: PyPI version

.. image:: https://img.shields.io/pypi/pyversions/pytest-pyvista.svg
.. image:: https://img.shields.io/conda/vn/conda-forge/pytest-pyvista?color=orange&label=conda-forge&logo=conda-forge&logoColor=white
:target: https://anaconda.org/conda-forge/pytest-pyvista
:alt: conda-forge version

.. image:: https://img.shields.io/pypi/pyversions/pytest-pyvista.svg?color=orange&logo=python&label=python&logoColor=white
:target: https://pypi.org/project/pytest-pyvista
:alt: Python versions

Expand Down Expand Up @@ -34,7 +38,7 @@ fail.

Requirements
------------
You must have a Python version greater than 3.7, as well as PyVista installed
You must have a Python version >= 3.8, as well as PyVista installed
in your environment.

pyvista version >=0.37.0 and vtk version >=9.0.0 required.
Expand All @@ -45,6 +49,9 @@ You can install "pytest-pyvista" via `pip`_ from `PyPI`_::

$ pip install pytest-pyvista

Alternatively, you can also install via `conda`_ or `mamba`_ from `conda-forge`_::

$ mamba install -c conda-forge pytest-pyvista

Usage
-----
Expand Down Expand Up @@ -104,6 +111,8 @@ These are the flags you can use when calling ``pytest`` in the command line:
* ``--image_cache_dir <DIR>`` sets the image cache dir. This will override any
configuration, see below.

* ``--reset_only_failed`` reset the image cache of the failed tests only.

Test specific flags
-------------------
These are attributes of `verify_image_cache`. You can set them as ``True`` if needed
Expand Down Expand Up @@ -164,3 +173,6 @@ description.
.. _`tox`: https://tox.readthedocs.io/en/latest/
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
.. _`conda`: https://github.com/conda/conda
.. _`mamba`: https://github.com/mamba-org/mamba
.. _`conda-forge`: https://anaconda.org/conda-forge/pytest-pyvista
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ classifiers=[
"Framework :: Pytest",
"Intended Audience :: Developers",
"Topic :: Software Development :: Testing",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -22,7 +21,7 @@ classifiers=[
"License :: OSI Approved :: MIT License",
]
dependencies=["pytest>=3.5.0"]
python_requires=">=3.7"
python_requires=">=3.8"

[project.urls]
Home = "https://github.com/pyvista/pytest-pyvista"
Expand All @@ -31,15 +30,16 @@ Home = "https://github.com/pyvista/pytest-pyvista"
[project.optional-dependencies]
tests = [
"codecov<2.2.0",
"coverage==7.2.2",
"coverage==7.3.1",
"pytest>=3.5.0",
"pytest-cov==4.0.0",
"numpy<1.24",
"pytest-cov==4.1.0",
"numpy<1.26",
]
docs = [
"pydata-sphinx-theme==0.13.1",
"sphinx_copybutton==0.5.1",
"sphinx-notfound-page==0.8.3",
"pydata-sphinx-theme==0.13.3",
"sphinx==7.2.6",
"sphinx_copybutton==0.5.2",
"sphinx-notfound-page==1.0.0",
]

[project.entry-points."pytest11"]
Expand Down
3 changes: 2 additions & 1 deletion pytest_pyvista/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Pytest-pyvista package"""

__version__ = "0.1.8"
__version__ = "0.1.9"


from .pytest_pyvista import VerifyImageCache
50 changes: 41 additions & 9 deletions pytest_pyvista/pytest_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
import pyvista


class RegressionError(RuntimeError):
"""Error when regression does not meet the criteria"""

pass


class RegressionFileNotFound(FileNotFoundError):
"""Error when regression file is not found"""

pass


def pytest_addoption(parser):
"""Adds new flag options to the pyvista plugin."""

Expand Down Expand Up @@ -45,6 +57,11 @@ def pytest_addoption(parser):
default="image_cache_dir",
help="Path to the image cache folder.",
)
group.addoption(
"--reset_only_failed",
action="store_true",
help="Reset only the failed images in the PyVista cache.",
)


class VerifyImageCache:
Expand Down Expand Up @@ -103,6 +120,7 @@ class VerifyImageCache:
ignore_image_cache = False
fail_extra_image_cache = False
add_missing_images = False
reset_only_failed = False

def __init__(
self,
Expand Down Expand Up @@ -183,37 +201,50 @@ def __call__(self, plotter):

# cached image name. We remove the first 5 characters of the function name
# "test_" to get the name for the image.
image_filename = os.path.join(self.cache_dir, test_name[5:] + ".png")
image_name = test_name[5:] + ".png"
image_filename = os.path.join(self.cache_dir, image_name)

if (
not os.path.isfile(image_filename)
and self.fail_extra_image_cache
and not self.reset_image_cache
):
# Make sure this doesn't get called again if this plotter doesn't close properly
plotter._before_close_callback = None
raise RuntimeError(f"{image_filename} does not exist in image cache")
raise RegressionFileNotFound(
f"{image_filename} does not exist in image cache"
)

if (
self.add_missing_images
and not os.path.isfile(image_filename)
or self.reset_image_cache
):
) and not self.reset_only_failed:
plotter.screenshot(image_filename)

if self.generated_image_dir is not None:
gen_image_filename = os.path.join(
self.generated_image_dir, test_name[5:] + ".png"
)
plotter.screenshot(gen_image_filename)

error = pyvista.compare_images(image_filename, plotter)

if error > allowed_error:
# Make sure this doesn't get called again if this plotter doesn't close properly
plotter._before_close_callback = None
raise RuntimeError(
f"{test_name} Exceeded image regression error of "
f"{allowed_error} with an image error equal to: {error}"
)
if self.reset_only_failed:
warnings.warn(
f"{test_name} Exceeded image regression error of "
f"{allowed_error} with an image error equal to: {error}"
f"\nThis image will be reset in the cache."
)
plotter.screenshot(image_filename)
else:
# Make sure this doesn't get called again if this plotter doesn't close properly
plotter._before_close_callback = None
raise RegressionError(
f"{test_name} Exceeded image regression error of "
f"{allowed_error} with an image error equal to: {error}"
)
if error > allowed_warning:
warnings.warn(
f"{test_name} Exceeded image regression warning of "
Expand All @@ -233,6 +264,7 @@ def verify_image_cache(request, pytestconfig):
"fail_extra_image_cache"
)
VerifyImageCache.add_missing_images = pytestconfig.getoption("add_missing_images")
VerifyImageCache.reset_only_failed = pytestconfig.getoption("reset_only_failed")

cache_dir = pytestconfig.getoption("image_cache_dir")
if cache_dir is None:
Expand Down
Loading

0 comments on commit 713eeb0

Please sign in to comment.