From 43b79764d5a4668d4cce7ccc32b1e047568f8815 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 29 May 2026 23:47:56 -0400 Subject: [PATCH 1/2] Fix test_RcParams_class on Python 3.15 The `repr` for dictionaries now wraps at the braces. For simplicitly, apply that on older versions as well. Also, shorten the list so it doesn't wrap and need any additional work. --- lib/matplotlib/tests/test_rcparams.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 0479fc7a02a8..22295f102a45 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -73,32 +73,34 @@ def func(): def test_RcParams_class(): - rc = mpl.RcParams({'font.cursive': ['Apple Chancery', - 'Textile', - 'Zapf Chancery', - 'cursive'], + rc = mpl.RcParams({'font.cursive': ['Zapf Chancery', 'cursive'], 'font.family': 'sans-serif', 'font.weight': 'normal', 'font.size': 12}) expected_repr = """ -RcParams({'font.cursive': ['Apple Chancery', - 'Textile', - 'Zapf Chancery', - 'cursive'], +RcParams({ + 'font.cursive': ['Zapf Chancery', 'cursive'], 'font.family': ['sans-serif'], 'font.size': 12.0, - 'font.weight': 'normal'})""".lstrip() + 'font.weight': 'normal', + })""".lstrip() - assert expected_repr == repr(rc) + actual_repr = repr(rc) + if sys.version_info[:2] < (3, 15): + actual_repr = (actual_repr + .replace("{'", "{\n '") + .replace("'}", "',\n }")) + + assert actual_repr == expected_repr expected_str = """ -font.cursive: ['Apple Chancery', 'Textile', 'Zapf Chancery', 'cursive'] +font.cursive: ['Zapf Chancery', 'cursive'] font.family: ['sans-serif'] font.size: 12.0 font.weight: normal""".lstrip() - assert expected_str == str(rc) + assert str(rc) == expected_str # test the find_all functionality assert ['font.cursive', 'font.size'] == sorted(rc.find_all('i[vz]')) From 5c2dfa32866d3027ff5cfeaae4b5cfba8eeacf6b Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Fri, 29 May 2026 23:56:03 -0400 Subject: [PATCH 2/2] TST: Ignore a new fork deprecation warning in Python 3.15 --- lib/matplotlib/tests/test_font_manager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/tests/test_font_manager.py b/lib/matplotlib/tests/test_font_manager.py index 73571298de4f..add063df9066 100644 --- a/lib/matplotlib/tests/test_font_manager.py +++ b/lib/matplotlib/tests/test_font_manager.py @@ -286,6 +286,9 @@ def _model_handler(_): reason='emscripten does not support subprocesses') @pytest.mark.skipif(not hasattr(os, "register_at_fork"), reason="Cannot register at_fork handlers") +# Python 3.15+ raises DeprecationWarning for fork in multi-threaded process +@pytest.mark.filterwarnings("ignore:.*multi-threaded.*fork.*:DeprecationWarning") +@pytest.mark.filterwarnings("ignore:.*multi-threaded.*fork.*:RuntimeWarning") def test_fork(): _model_handler(0) # Make sure the font cache is filled. ctx = multiprocessing.get_context("fork")