From 5fb45b8f3f3edf6dff9105c784022dc56b4dbab2 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 6 Jun 2023 22:39:43 -0400 Subject: [PATCH 1/4] TST: Move locale comma test to a subprocess On some systems/pytest versions, the skip in an exception handler does not skip, but is treated as an exception. Namely, the ARM test machine in Cirrus and on my WSL Ubuntu. --- lib/matplotlib/tests/test_ticker.py | 40 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index c95526ecf987..9d08e335dbdd 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -1640,22 +1640,36 @@ def test_latex(self, is_latex, usetex, expected): assert fmt.format_pct(50, 100) == expected -def test_locale_comma(): - currentLocale = locale.getlocale() +def _impl_locale_comma(): try: locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') - ticks = mticker.ScalarFormatter(useMathText=True, useLocale=True) - fmt = '$\\mathdefault{%1.1f}$' - x = ticks._format_maybe_minus_and_locale(fmt, 0.5) - assert x == '$\\mathdefault{0{,}5}$' - # Do not change , in the format string - fmt = ',$\\mathdefault{,%1.1f},$' - x = ticks._format_maybe_minus_and_locale(fmt, 0.5) - assert x == ',$\\mathdefault{,0{,}5},$' except locale.Error: - pytest.skip("Locale de_DE.UTF-8 is not supported on this machine") - finally: - locale.setlocale(locale.LC_ALL, currentLocale) + print('SKIP: Locale de_DE.UTF-8 is not supported on this machine') + return + ticks = mticker.ScalarFormatter(useMathText=True, useLocale=True) + fmt = '$\\mathdefault{%1.1f}$' + x = ticks._format_maybe_minus_and_locale(fmt, 0.5) + assert x == '$\\mathdefault{0{,}5}$' + # Do not change , in the format string + fmt = ',$\\mathdefault{,%1.1f},$' + x = ticks._format_maybe_minus_and_locale(fmt, 0.5) + assert x == ',$\\mathdefault{,0{,}5},$' + + +def test_locale_comma(): + # On some systems/pytest versions, `pytest.skip` in an exception handler + # does not skip, but is treated as an exception, so directly running this + # test can incorrectly fail instead of skip. + # Instead, run this test in a subprocess, which avoids the problem, and the + # need to fix the locale after. + proc = mpl.testing.subprocess_run_helper(_impl_locale_comma, timeout=60, + extra_env={'MPLBACKEND': 'Agg'}) + skip_msg = next((line[len('SKIP:'):].strip() + for line in proc.stdout.splitlines() + if line.startswith('SKIP:')), + '') + if skip_msg: + pytest.skip(skip_msg) def test_majformatter_type(): From 4bb4dc7d9d47fb483fcbc5a7e5ba7271153bdc36 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 31 Jul 2023 23:49:42 -0400 Subject: [PATCH 2/4] Use Agg backend in pickle test subprocess The main parent process is using Agg, so the subprocess should as well, to be able to unpickle correctly. --- lib/matplotlib/tests/test_pickle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_pickle.py b/lib/matplotlib/tests/test_pickle.py index 8d1e20b4cb93..e222a495e437 100644 --- a/lib/matplotlib/tests/test_pickle.py +++ b/lib/matplotlib/tests/test_pickle.py @@ -143,7 +143,7 @@ def test_pickle_load_from_subprocess(fig_test, fig_ref, tmp_path): proc = subprocess_run_helper( _pickle_load_subprocess, timeout=60, - extra_env={'PICKLE_FILE_PATH': str(fp)} + extra_env={'PICKLE_FILE_PATH': str(fp), 'MPLBACKEND': 'Agg'} ) loaded_fig = pickle.loads(ast.literal_eval(proc.stdout)) From 8530b1f2d6fd9fae1baf25b2c9d79471dd91f690 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 11 Aug 2023 19:12:09 -0400 Subject: [PATCH 3/4] TST: Mark macosx backend in leak test as xfail --- lib/matplotlib/tests/test_backends_interactive.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index dbc0f0928b74..e15e591b1b10 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -660,7 +660,7 @@ def _test_figure_leak(): reason="appveyor tests fail; gh-22988 suggests reworking") @pytest.mark.parametrize("env", _get_testable_interactive_backends()) @pytest.mark.parametrize("time_mem", [(0.0, 2_000_000), (0.1, 30_000_000)]) -def test_figure_leak_20490(env, time_mem): +def test_figure_leak_20490(env, time_mem, request): pytest.importorskip("psutil", reason="psutil needed to run this test") # We haven't yet directly identified the leaks so test with a memory growth @@ -669,9 +669,10 @@ def test_figure_leak_20490(env, time_mem): if env["MPLBACKEND"] == "wx": pytest.skip("wx backend is deprecated; tests failed on appveyor") - if env["MPLBACKEND"] == "macosx" or ( - env["MPLBACKEND"] == "tkagg" and sys.platform == 'darwin' - ): + if env["MPLBACKEND"] == "macosx": + request.node.add_marker(pytest.mark.xfail(reason="macosx backend is leaky")) + + if env["MPLBACKEND"] == "tkagg" and sys.platform == "darwin": acceptable_memory_leakage += 11_000_000 result = _run_helper( From 02263d2654183df374e467eaad6066e66daf6873 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 11 Aug 2023 21:00:57 -0400 Subject: [PATCH 4/4] TST: Mark test_other_signal_before_sigint mac as xfail --- lib/matplotlib/tests/test_backends_interactive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index e15e591b1b10..6048b2647b17 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -816,12 +816,12 @@ def custom_signal_handler(signum, frame): ('show', {'block': True}), ('pause', {'interval': 10}) ]) -def test_other_signal_before_sigint(env, target, kwargs): +def test_other_signal_before_sigint(env, target, kwargs, request): backend = env.get("MPLBACKEND") if not backend.startswith(("qt", "macosx")): pytest.skip("SIGINT currently only tested on qt and macosx") - if backend == "macosx" and target == "show": - pytest.xfail("test currently failing for macosx + show()") + if backend == "macosx": + request.node.add_marker(pytest.mark.xfail(reason="macosx backend is buggy")) proc = _WaitForStringPopen( [sys.executable, "-c", inspect.getsource(_test_other_signal_before_sigint_impl) + pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy