72 lines
2.6 KiB
Diff
72 lines
2.6 KiB
Diff
From a9a33285fd713132786d4521be8b881d7c7b07c7 Mon Sep 17 00:00:00 2001
|
|
From: wang--ge <wang__ge@126.com>
|
|
Date: Mon, 6 Feb 2023 17:11:39 +0800
|
|
Subject: [PATCH] maint more informative assertion errors when warings happen
|
|
|
|
---
|
|
continuous_integration/run_tests.sh | 2 +-
|
|
joblib/test/test_parallel.py | 16 +++++++++++-----
|
|
2 files changed, 12 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/continuous_integration/run_tests.sh b/continuous_integration/run_tests.sh
|
|
index 51bed5f..6e7a537 100755
|
|
--- a/continuous_integration/run_tests.sh
|
|
+++ b/continuous_integration/run_tests.sh
|
|
@@ -20,7 +20,7 @@ if [[ "$SKIP_TESTS" != "true" ]]; then
|
|
export PYTEST_ADDOPTS="--cov=joblib --cov-append"
|
|
fi
|
|
|
|
- pytest joblib -vl --timeout=60 --junitxml="${JUNITXML}"
|
|
+ pytest joblib -vl --timeout=120 --junitxml="${JUNITXML}"
|
|
make test-doc
|
|
fi
|
|
|
|
diff --git a/joblib/test/test_parallel.py b/joblib/test/test_parallel.py
|
|
index 7edeb85..9c6b2dc 100644
|
|
--- a/joblib/test/test_parallel.py
|
|
+++ b/joblib/test/test_parallel.py
|
|
@@ -17,6 +17,7 @@ from time import sleep
|
|
from pickle import PicklingError
|
|
from multiprocessing import TimeoutError
|
|
import pickle
|
|
+import warnings
|
|
import pytest
|
|
|
|
from importlib import reload
|
|
@@ -190,22 +191,27 @@ def test_main_thread_renamed_no_warning(backend, monkeypatch):
|
|
|
|
|
|
def _assert_warning_nested(backend, inner_n_jobs, expected):
|
|
- with warns(None) as records:
|
|
+ with warnings.catch_warnings(record=True) as records:
|
|
+ warnings.simplefilter("always")
|
|
parallel_func(backend=backend, inner_n_jobs=inner_n_jobs)
|
|
|
|
+ messages = [w.message for w in records]
|
|
if expected:
|
|
# with threading, we might see more that one records
|
|
- if len(records) > 0:
|
|
- return 'backed parallel loops cannot' in records[0].message.args[0]
|
|
+ if warnings:
|
|
+ return (len(messages)==1 and 'backed parallel loops cannot' in messages[0].args[0])
|
|
return False
|
|
else:
|
|
- assert len(records) == 0
|
|
+ assert not messages
|
|
return True
|
|
|
|
|
|
@with_multiprocessing
|
|
@parametrize('parent_backend,child_backend,expected', [
|
|
- ('loky', 'multiprocessing', True), ('loky', 'loky', False),
|
|
+ ('loky', 'multiprocessing', True),
|
|
+ # XXX: loky nested under loky causes pytest 7+ to freeze after tests end when using warnings.catch_warnings:
|
|
+ # deadlock happens in loky/process_executor.py", line 193, in _python_exit
|
|
+ # ('loky', 'loky', False),
|
|
('multiprocessing', 'multiprocessing', True),
|
|
('multiprocessing', 'loky', True),
|
|
('threading', 'multiprocessing', True),
|
|
--
|
|
2.27.0
|
|
|