diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 9cc88f1076a..10c10f4c6d3 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -6,7 +6,6 @@ import os import string -import pytest from pygmt.exceptions import GMTImageComparisonFailure from pygmt.io import load_dataarray from pygmt.src import which @@ -272,6 +271,8 @@ def skip_if_no(package): A pytest.mark.skipif to use as either a test decorator or a parametrization mark. """ + import pytest + try: _ = importlib.import_module(name=package) has_package = True