aports/community/py3-matplotlib/pytest8.patch
2024-04-12 11:59:22 +02:00

71 lines
2.8 KiB
Diff

From 9fd9a42625e0aa3c223d5ecf0ccc15ff20efc107 Mon Sep 17 00:00:00 2001
From: Kyle Sunden <git@ksunden.space>
Date: Tue, 9 Jan 2024 17:59:38 -0600
Subject: [PATCH] Prepare for Pytest v8
The behavior of pytest.warns has changed, particularly with regards to handling of additional warnings
---
lib/matplotlib/tests/test_backend_pdf.py | 4 ++++
lib/matplotlib/tests/test_colors.py | 3 +--
lib/matplotlib/tests/test_rcparams.py | 6 ++----
lib/matplotlib/tests/test_ticker.py | 4 ++++
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py
index 139efbe17407..73afc1da8a37 100644
--- a/lib/matplotlib/tests/test_colors.py
+++ b/lib/matplotlib/tests/test_colors.py
@@ -147,8 +147,7 @@ def test_double_register_builtin_cmap():
with pytest.raises(ValueError, match='A colormap named "viridis"'):
with pytest.warns(mpl.MatplotlibDeprecationWarning):
cm.register_cmap(name, mpl.colormaps[name])
- with pytest.warns(UserWarning):
- # TODO is warning more than once!
+ with pytest.warns(UserWarning), pytest.warns(mpl.MatplotlibDeprecationWarning):
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py
index e3e10145533d..782c390c9462 100644
--- a/lib/matplotlib/tests/test_rcparams.py
+++ b/lib/matplotlib/tests/test_rcparams.py
@@ -106,14 +106,12 @@ def test_rcparams_update():
rc = mpl.RcParams({'figure.figsize': (3.5, 42)})
bad_dict = {'figure.figsize': (3.5, 42, 1)}
# make sure validation happens on input
- with pytest.raises(ValueError), \
- pytest.warns(UserWarning, match="validate"):
+ with pytest.raises(ValueError):
rc.update(bad_dict)
def test_rcparams_init():
- with pytest.raises(ValueError), \
- pytest.warns(UserWarning, match="validate"):
+ with pytest.raises(ValueError):
mpl.RcParams({'figure.figsize': (3.5, 42, 1)})
diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py
index 12eafba9ea2b..1e15bade5d59 100644
--- a/lib/matplotlib/tests/test_ticker.py
+++ b/lib/matplotlib/tests/test_ticker.py
@@ -3,6 +3,7 @@
import locale
import logging
import re
+import warnings
import numpy as np
from numpy.testing import assert_almost_equal, assert_array_equal
@@ -914,6 +915,9 @@ def test_mathtext_ticks(self):
'axes.formatter.use_mathtext': False
})
+ # Glyph warning unrelated
+ warnings.filterwarnings("ignore", category=UserWarning, message="Glyph 8722")
+
with pytest.warns(UserWarning, match='cmr10 font should ideally'):
fig, ax = plt.subplots()
ax.set_xticks([-1, 0, 1])