Skip to content

Commit ed41aea

Browse files
authored
Merge pull request #27624 from ksunden/pytest8
Prepare for Pytest v8
2 parents fd332aa + f0a1577 commit ed41aea

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,7 @@ def close(self):
27252725
_api.warn_deprecated("3.8", message=(
27262726
"Keeping empty pdf files is deprecated since %(since)s and support "
27272727
"will be removed %(removal)s."))
2728-
PdfFile(self._filename, metadata=self._metadata) # touch the file.
2728+
PdfFile(self._filename, metadata=self._metadata).close() # touch the file.
27292729

27302730
def infodict(self):
27312731
"""

lib/matplotlib/tests/test_colors.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
import itertools
33
import unittest.mock
4+
from packaging.version import parse as parse_version
45

56
from io import BytesIO
67
import numpy as np
@@ -147,9 +148,13 @@ def test_double_register_builtin_cmap():
147148
with pytest.raises(ValueError, match='A colormap named "viridis"'):
148149
with pytest.warns(mpl.MatplotlibDeprecationWarning):
149150
cm.register_cmap(name, mpl.colormaps[name])
150-
with pytest.warns(UserWarning):
151-
# TODO is warning more than once!
152-
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
151+
152+
if parse_version(pytest.__version__).major < 8:
153+
with pytest.warns(UserWarning):
154+
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
155+
else:
156+
with pytest.warns(UserWarning), pytest.warns(mpl.MatplotlibDeprecationWarning):
157+
cm.register_cmap(name, mpl.colormaps[name], override_builtin=True)
153158

154159

155160
def test_unregister_builtin_cmap():

lib/matplotlib/tests/test_rcparams.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,12 @@ def test_rcparams_update():
106106
rc = mpl.RcParams({'figure.figsize': (3.5, 42)})
107107
bad_dict = {'figure.figsize': (3.5, 42, 1)}
108108
# make sure validation happens on input
109-
with pytest.raises(ValueError), \
110-
pytest.warns(UserWarning, match="validate"):
109+
with pytest.raises(ValueError):
111110
rc.update(bad_dict)
112111

113112

114113
def test_rcparams_init():
115-
with pytest.raises(ValueError), \
116-
pytest.warns(UserWarning, match="validate"):
114+
with pytest.raises(ValueError):
117115
mpl.RcParams({'figure.figsize': (3.5, 42, 1)})
118116

119117

lib/matplotlib/tests/test_ticker.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import locale
44
import logging
55
import re
6+
from packaging.version import parse as parse_version
67

78
import numpy as np
89
from numpy.testing import assert_almost_equal, assert_array_equal
@@ -914,10 +915,17 @@ def test_mathtext_ticks(self):
914915
'axes.formatter.use_mathtext': False
915916
})
916917

917-
with pytest.warns(UserWarning, match='cmr10 font should ideally'):
918-
fig, ax = plt.subplots()
919-
ax.set_xticks([-1, 0, 1])
920-
fig.canvas.draw()
918+
if parse_version(pytest.__version__).major < 8:
919+
with pytest.warns(UserWarning, match='cmr10 font should ideally'):
920+
fig, ax = plt.subplots()
921+
ax.set_xticks([-1, 0, 1])
922+
fig.canvas.draw()
923+
else:
924+
with (pytest.warns(UserWarning, match="Glyph 8722"),
925+
pytest.warns(UserWarning, match='cmr10 font should ideally')):
926+
fig, ax = plt.subplots()
927+
ax.set_xticks([-1, 0, 1])
928+
fig.canvas.draw()
921929

922930
def test_cmr10_substitutions(self, caplog):
923931
mpl.rcParams.update({

0 commit comments

Comments
 (0)
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