1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
From: Ole Streicher <olebole@debian.org>
Date: Tue, 10 May 2022 09:51:49 +0200
Subject: Skip some tests when opencv is not available
OpenCV may be installed on Python, however it is installed for the
default Python version only, so it will fail on the other Python
versions if more than one is installed.
---
sunpy/image/tests/test_transform.py | 8 ++++++++
sunpy/map/tests/test_mapbase.py | 6 ++++++
2 files changed, 14 insertions(+)
diff --git a/sunpy/image/tests/test_transform.py b/sunpy/image/tests/test_transform.py
index 4aa7e6c..0b2d6f5 100644
--- a/sunpy/image/tests/test_transform.py
+++ b/sunpy/image/tests/test_transform.py
@@ -10,6 +10,11 @@ from sunpy.image.transform import _rotation_registry, affine_transform
from sunpy.tests.helpers import figure_test, skip_windows
from sunpy.util import SunpyUserWarning
+try:
+ import opencv
+except ImportError:
+ opencv = None
+
# Tolerance for tests
RTOL = 1.0e-10
@@ -265,6 +270,7 @@ def test_reproducible_matrix_multiplication():
assert np.sum(mismatches != 0) == 0
+@pytest.mark.skipif(opencv is None, reason="The opencv-python package is unavailable")
@figure_test
def test_clipping(rot30):
# Generates a plot to test the clipping the output image to the range of the input image
@@ -297,6 +303,7 @@ def test_clipping(rot30):
return fig
+@pytest.mark.skipif(opencv is None, reason="The opencv-python package is unavailable")
@pytest.mark.filterwarnings("ignore:.*bug in the implementation of scikit-image")
@figure_test
def test_nans(rot30):
@@ -330,6 +337,7 @@ def test_nans(rot30):
return fig
+@pytest.mark.skipif(opencv is None, reason="The opencv-python package is unavailable")
@pytest.mark.filterwarnings("ignore:.*bug in the implementation of scikit-image")
@pytest.mark.parametrize('method', _rotation_registry.keys())
@pytest.mark.parametrize('order', range(6))
diff --git a/sunpy/map/tests/test_mapbase.py b/sunpy/map/tests/test_mapbase.py
index 9bb0212..9b7d5ad 100644
--- a/sunpy/map/tests/test_mapbase.py
+++ b/sunpy/map/tests/test_mapbase.py
@@ -39,6 +39,11 @@ from sunpy.util.exceptions import SunpyDeprecationWarning, SunpyMetadataWarning
from sunpy.util.metadata import ModifiedItem
from .strategies import matrix_meta
+try:
+ import opencv
+except ImportError:
+ opencv = None
+
def test_fits_data_comparison(aia171_test_map):
"""Make sure the data is the same when read with astropy.io.fits and sunpy"""
@@ -1735,6 +1740,7 @@ def test_draw_carrington_map(carrington_map):
return fig
+@pytest.mark.skipif(opencv is None, reason="The opencv-python package is unavailable")
@pytest.mark.parametrize('method', _rotation_registry.keys())
@figure_test
def test_derotating_nonpurerotation_pcij(aia171_test_map, method):
|