From f18ef2643f3e5b02c9de977b515b7239a5fadef7 Mon Sep 17 00:00:00 2001 From: Ricci Adams <1097294+iccir@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:31:06 -0700 Subject: [PATCH] Backport PR #32198: TST: Set subprocess timeouts consistently on CI --- lib/matplotlib/testing/__init__.py | 2 ++ lib/matplotlib/tests/test_backends_interactive.py | 5 +++-- lib/matplotlib/tests/test_getattr.py | 6 +++--- lib/matplotlib/tests/test_pickle.py | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/testing/__init__.py b/lib/matplotlib/testing/__init__.py index fdbf79014611..68fb66f6824d 100644 --- a/lib/matplotlib/testing/__init__.py +++ b/lib/matplotlib/testing/__init__.py @@ -143,6 +143,8 @@ def subprocess_run_helper(func, *args, timeout, extra_env=None): extra_env : dict[str, str] Any additional environment variables to be set for the subprocess. """ + if is_ci_environment(): + timeout *= 6 target = func.__name__ module = func.__module__ file = func.__code__.co_filename diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index 5d76300054d7..701b9e7beba8 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -119,8 +119,9 @@ def _get_testable_interactive_backends(): for env, marks in _get_available_interactive_backends()] -# Reasonable safe values for slower CI/Remote and local architectures. -_test_timeout = 120 if is_ci_environment() else 20 +# Reasonable safe values for slower CI/Remote and local architectures; timeouts may be +# automatically increased later by subprocess_run_helper. +_test_timeout = 20 _retry_count = 3 if is_ci_environment() else 0 diff --git a/lib/matplotlib/tests/test_getattr.py b/lib/matplotlib/tests/test_getattr.py index fe302220067a..91b2d460574d 100644 --- a/lib/matplotlib/tests/test_getattr.py +++ b/lib/matplotlib/tests/test_getattr.py @@ -6,7 +6,8 @@ import pytest import matplotlib -from matplotlib.testing import is_ci_environment, subprocess_run_helper +from matplotlib.testing import subprocess_run_helper + # Get the names of all matplotlib submodules, # except for the unit tests and private modules. @@ -59,8 +60,7 @@ def _test_module_getattr(): @pytest.mark.parametrize('module_name', backend_module_names) def test_backend_getattr(module_name): - proc = subprocess_run_helper(_test_module_getattr, module_name, - timeout=120 if is_ci_environment() else 20) + proc = subprocess_run_helper(_test_module_getattr, module_name, timeout=20) if 'SKIP: ' in proc.stdout: pytest.skip(proc.stdout.removeprefix('SKIP: ')) print(proc.stdout) diff --git a/lib/matplotlib/tests/test_pickle.py b/lib/matplotlib/tests/test_pickle.py index 3494dceffe5d..4c552e7eafb0 100644 --- a/lib/matplotlib/tests/test_pickle.py +++ b/lib/matplotlib/tests/test_pickle.py @@ -10,7 +10,7 @@ import matplotlib as mpl from matplotlib import cm -from matplotlib.testing import subprocess_run_helper, is_ci_environment +from matplotlib.testing import subprocess_run_helper from matplotlib.testing.decorators import check_figures_equal from matplotlib.dates import rrulewrapper # type: ignore[attr-defined] from matplotlib.lines import VertexSelector @@ -326,6 +326,6 @@ def _test_axeswidget_interactive(): def test_axeswidget_interactive(): subprocess_run_helper( _test_axeswidget_interactive, - timeout=120 if is_ci_environment() else 20, + timeout=20, extra_env={'MPLBACKEND': 'tkagg'} )