-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Incompatibility with Python 3.15 alpha 7 #31429
Description
We are already building RPM packages with Python 3.15 alpha 7 in Fedora Linux and I've found some issues and solutions for them.
call_count in Mock
Since python/cpython@850f95f, call_count is now calculated property, so setting call_count = 0 in tests does not work as before and does not actually reset the counter.
My solution for test_norma_callback:
--- a/lib/matplotlib/tests/test_colors.py
+++ b/lib/matplotlib/tests/test_colors.py
@@ -1590,7 +1590,9 @@ def test_norm_callback():
assert increment.call_count == 2
# We only want autoscale() calls to send out one update signal
- increment.call_count = 0
+ # Python 3.15: Mock.call_count is now a computed property based on
+ # len(call_args_list), so setting call_count=0 no longer works.
+ increment.reset_mock()
norm.autoscale([0, 1, 2])
assert increment.call_count == 1tolerances
I have to increase tolerances in test_pcolornearestunits and test_rcupdate – I don't know whether this is realted to Python 3.15 or not though.
--- a/lib/matplotlib/tests/test_axes.py
+++ b/lib/matplotlib/tests/test_axes.py
@@ -1668,7 +1668,7 @@ def test_pcolornearest(fig_test, fig_ref):
ax.pcolormesh(x2, y2, Z, shading='nearest')
-@check_figures_equal(extensions=["png"])
+@check_figures_equal(extensions=["png"], tol=5.0)
def test_pcolornearestunits(fig_test, fig_ref):
ax = fig_test.subplots()
x = [datetime.datetime.fromtimestamp(x * 3600) for x in range(10)]and
--- a/lib/matplotlib/tests/test_backend_pgf.py
+++ b/lib/matplotlib/tests/test_backend_pgf.py
@@ -131,7 +131,7 @@ def test_rcupdate():
'pgf.preamble': ('\\usepackage[utf8x]{inputenc}'
'\\usepackage[T1]{fontenc}'
'\\usepackage{sfmath}')}]
- tol = [0, 13.2] if _old_gs_version else [0, 0]
+ tol = [0, 13.2] if _old_gs_version else [0, 5.0] # Increased tolerance for Python 3.15
for i, rc_set in enumerate(rc_sets):
with mpl.rc_context(rc_set):
for substring, pkg in [('sfmath', 'sfmath'), ('utf8x', 'ucs')]:Silenced deprecation warnings
I have to silence gi.PyGIDeprecationWarning: GLib.unix_signal_add_full is deprecated; use GLibUnix.signal_add_full instead and DeprecationWarning: This process (pid=13234) is multi-threaded, use of fork() may lead to deadlocks in the child.. Only the second one is coming from Python itself but both might be important for new releases of matplotlib.
--- a/lib/matplotlib/tests/test_backend_gtk3.py
+++ b/lib/matplotlib/tests/test_backend_gtk3.py
@@ -6,6 +6,8 @@ from unittest import mock
@pytest.mark.backend("gtk3agg", skip_on_importerror=True)
+@pytest.mark.filterwarnings("ignore:.*unix_signal_add_full.*:gi.PyGIDeprecationWarning")
+@pytest.mark.filterwarnings("ignore:.*unix_signal_add_full.*:DeprecationWarning")
def test_correct_key():
pytest.xfail("test_widget_send_event is not triggering key_press_event")
and
--- a/lib/matplotlib/tests/test_font_manager.py
+++ b/lib/matplotlib/tests/test_font_manager.py
@@ -230,6 +230,9 @@ def _model_handler(_):
@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")