Allow tests to fail if multiprocessing is not available
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sat, 21 Sep 2024 11:58:14 +0000 (12:58 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sat, 21 Sep 2024 11:58:14 +0000 (12:58 +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 36d487ff62c2b5278329cbe199c693854a286478..b25140722b624660772b65347c3d61132da52f09 100644 (file)
@@ -14,6 +14,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()
@@ -59,6 +65,10 @@ def test_hdr_basic(close_figures):
         outliers = labels[labels_pos]
         assert_equal([1982, 1983, 1997, 1998], outliers)
         assert_equal(labels[hdr.outliers_idx], outliers)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -73,6 +83,10 @@ def test_hdr_basic_brute(close_figures, reset_randomstate):
                     21.231, 20.366, 20.168, 20.434, 21.111, 22.299]
 
         assert_almost_equal(hdr.median, median_t, decimal=2)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -92,6 +106,10 @@ def test_hdr_plot(close_figures):
         ax.set_xticks(np.arange(13, step=3) - 1)
         ax.set_xticklabels(["", "Mar", "Jun", "Sep", "Dec"])
         ax.set_xlim([-0.2, 11.2])
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -107,6 +125,10 @@ def test_hdr_alpha(close_figures):
                                    [23.4, 24.8, 25.0, 23.9, 22.4, 21.1,
                                     20.0, 19.3, 19.2, 19.4, 20.1, 21.3]])
         assert_almost_equal(hdr.extra_quantiles, extra_quant_t, decimal=0)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -131,6 +153,10 @@ def test_hdr_multiple_alpha(close_figures):
                           19.697, 19.951, 20.622, 21.858]]
         assert_almost_equal(hdr.extra_quantiles, np.vstack(extra_quant_t),
                             decimal=0)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -145,6 +171,10 @@ def test_hdr_threshold(close_figures):
                             axis=1)
         outliers = labels[labels_pos]
         assert_equal([1968, 1982, 1983, 1997, 1998], outliers)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -158,6 +188,10 @@ def test_hdr_bw(close_figures):
 
                     21.31, 20.44, 20.24, 20.51, 21.19, 22.38]
         assert_almost_equal(hdr.median, median_t, decimal=2)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')
 
@@ -170,6 +204,10 @@ def test_hdr_ncomp(close_figures):
         median_t = [24.33, 25.71, 26.04, 25.08, 23.74, 22.40,
                     21.32, 20.45, 20.25, 20.53, 21.20, 22.39]
         assert_almost_equal(hdr.median, median_t, decimal=2)
+    except ImportError:
+        if not has_multiprocessing:
+            pytest.xfail('Multiprocess not available')
+        raise
     except OSError:
         pytest.xfail('Multiprocess randomly crashes in Windows testing')