From 8e5b0b95b50dbecc8c208be3d34288074b948b78 Mon Sep 17 00:00:00 2001 From: Waleed-Abdullah Date: Sun, 2 Jul 2023 18:21:25 +0500 Subject: [PATCH] decreased timeout for local interactive tests --- .../tests/test_backends_interactive.py | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index f198f2c95612..1eb5e1da58d1 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -79,7 +79,29 @@ def _get_testable_interactive_backends(): return envs -_test_timeout = 120 # A reasonably safe value for slower architectures. +def is_ci_environment(): + # Common CI variables + ci_environment_variables = [ + 'CI', # Generic CI environment variable + 'CONTINUOUS_INTEGRATION', # Generic CI environment variable + 'TRAVIS', # Travis CI + 'CIRCLECI', # CircleCI + 'JENKINS', # Jenkins + 'GITLAB_CI', # GitLab CI + 'GITHUB_ACTIONS', # GitHub Actions + 'TEAMCITY_VERSION' # TeamCity + # Add other CI environment variables as needed + ] + + for env_var in ci_environment_variables: + if os.getenv(env_var): + return True + + return False + + +# Reasonable safe values for slower CI/Remote and local architectures. +_test_timeout = 120 if is_ci_environment() else 20 def _test_toolbar_button_la_mode_icon(fig): @@ -204,15 +226,15 @@ def test_interactive_backend(env, toolbar): pytest.skip("wx backend is deprecated; tests failed on appveyor") try: proc = _run_helper( - _test_interactive_impl, - json.dumps({"toolbar": toolbar}), - timeout=_test_timeout, - extra_env=env, - ) + _test_interactive_impl, + json.dumps({"toolbar": toolbar}), + timeout=_test_timeout, + extra_env=env, + ) except subprocess.CalledProcessError as err: pytest.fail( - "Subprocess failed to test intended behavior\n" - + str(err.stderr)) + "Subprocess failed to test intended behavior\n" + + str(err.stderr)) assert proc.stdout.count("CloseEvent") == 1