From 6987ae84afcf952a50d06925206ec835c60b3d04 Mon Sep 17 00:00:00 2001 From: Debian Science Maintainers Date: Sat, 5 Oct 2024 11:43:25 +0100 Subject: [PATCH] Allow tests to fail if multiprocessing is not available This is currently the case on hurd-i386 Author: Rebecca N. Palmer Forwarded: no Gbp-Pq: Name xfail_no_multiprocessing.patch --- statsmodels/graphics/tests/test_functional.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/statsmodels/graphics/tests/test_functional.py b/statsmodels/graphics/tests/test_functional.py index 5be3ce8..900085a 100644 --- a/statsmodels/graphics/tests/test_functional.py +++ b/statsmodels/graphics/tests/test_functional.py @@ -15,6 +15,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() @@ -64,6 +70,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') @@ -78,6 +88,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') @@ -101,6 +115,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') @@ -120,6 +138,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') @@ -148,6 +170,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') @@ -166,6 +192,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') @@ -183,6 +213,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') @@ -199,6 +233,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') -- 2.30.2