diff --git a/tests/plotting/test_examples.py b/tests/plotting/test_examples.py index 6edbe272..5a6df60a 100644 --- a/tests/plotting/test_examples.py +++ b/tests/plotting/test_examples.py @@ -1,5 +1,6 @@ """Unit-tests for :mod:`geovista.examples`.""" import importlib +import os import pkgutil import pytest @@ -8,6 +9,11 @@ import geovista as gv import geovista.examples +# determine whether running on GHA runner +# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables +CI: bool = os.environ.get("CI", "false").lower() == "true" + + # construct list of example script names SCRIPTS = sorted( [submodule.name for submodule in pkgutil.iter_modules(gv.examples.__path__)] @@ -17,11 +23,22 @@ pv.OFF_SCREEN = True gv.GEOVISTA_IMAGE_TESTING = True +# individual test case exceptions to the default image tolerances +thresholds = { + "from_points__orca_cloud": {"warning_value": 202.0}, + "from_points__orca_cloud_eqc": {"warning_value": 250.0}, +} + @pytest.mark.image @pytest.mark.parametrize("script", SCRIPTS) def test(script, verify_image_cache): """Image test the example scripts.""" + # apply individual test case image tolerance exceptions only when + # executing within a remote GHA runner environment + if CI and script in thresholds: + for attr, value in thresholds[script].items(): + setattr(verify_image_cache, attr, value) verify_image_cache.test_name = f"test_{script}" module = importlib.import_module(f"geovista.examples.{script}") module.main() diff --git a/tox.ini b/tox.ini index 158efe42..80ceab2a 100644 --- a/tox.ini +++ b/tox.ini @@ -61,6 +61,7 @@ description = platform = linux passenv = + CI CODECOV_TOKEN POST_COMMAND setenv =