From 5588030a9aac585cdcb1235430252fb4bff2913d Mon Sep 17 00:00:00 2001 From: Debian Science Maintainers Date: Sat, 21 Sep 2024 12:58:14 +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 36d487f..b251407 100644 --- a/statsmodels/graphics/tests/test_functional.py +++ b/statsmodels/graphics/tests/test_functional.py @@ -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') -- 2.30.2