Allow tests to fail if multiprocessing is not available
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sun, 29 Aug 2021 19:09:28 +0000 (20:09 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sun, 29 Aug 2021 19:09:28 +0000 (20:09 +0100)
This is currently the case on hurd-i386

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name xfail_no_multiprocessing.patch

statsmodels/graphics/tests/test_functional.py

index 156f9ec96765fabea12e884ea06ebd06fe361204..34ba43b8dadccf512c46b8abe278ee93bc2429ab 100644 (file)
@@ -11,6 +11,12 @@ try:
     import matplotlib.pyplot as plt
 except ImportError:
     pass
+has_multiprocessing = True
+try:
+    import multiprocessing
+    multiprocessing.Pool()
+except ImportError:
+    has_multiprocessing = False
 
 
 data = elnino.load(as_pandas=False)
@@ -22,6 +28,10 @@ data = data.raw_data[:, 1:]
 def test_hdr_basic(close_figures):
     try:
         _, hdr = hdrboxplot(data, labels=labels, seed=12345)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -64,6 +74,10 @@ def test_hdr_basic(close_figures):
 def test_hdr_basic_brute(close_figures, reset_randomstate):
     try:
         _, hdr = hdrboxplot(data, ncomp=2, labels=labels, use_brute=True)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -99,6 +113,10 @@ def test_hdr_plot(close_figures):
 def test_hdr_alpha(close_figures):
     try:
         _, hdr = hdrboxplot(data, alpha=[0.7], seed=12345)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -114,6 +132,10 @@ def test_hdr_alpha(close_figures):
 def test_hdr_multiple_alpha(close_figures):
     try:
         _, hdr = hdrboxplot(data, alpha=[0.4, 0.92], seed=12345)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -139,6 +161,10 @@ def test_hdr_threshold(close_figures):
     try:
         _, hdr = hdrboxplot(data, alpha=[0.8], threshold=0.93,
                             seed=12345)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -152,6 +178,10 @@ def test_hdr_threshold(close_figures):
 def test_hdr_bw(close_figures):
     try:
         _, hdr = hdrboxplot(data, bw='cv_ml', seed=12345)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -165,6 +195,10 @@ def test_hdr_bw(close_figures):
 def test_hdr_ncomp(close_figures):
     try:
         _, hdr = hdrboxplot(data, ncomp=3, seed=12345)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except WindowsError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')