diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index aa4883135d92..facb8efec819 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -2732,7 +2732,7 @@ def close(self): _api.warn_deprecated("3.8", message=( "Keeping empty pdf files is deprecated since %(since)s and support " "will be removed %(removal)s.")) - PdfFile(self._filename, metadata=self._metadata) # touch the file. + PdfFile(self._filename, metadata=self._metadata).close() # touch the file. def infodict(self): """ diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 139efbe17407..35030b6bea7a 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1,6 +1,7 @@ import copy import itertools import unittest.mock +from packaging.version import parse as parse_version from io import BytesIO import numpy as np @@ -147,9 +148,13 @@ 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! - cm.register_cmap(name, mpl.colormaps[name], override_builtin=True) + + if parse_version(pytest.__version__).major < 8: + with pytest.warns(UserWarning): + cm.register_cmap(name, mpl.colormaps[name], override_builtin=True) + else: + with pytest.warns(UserWarning), pytest.warns(mpl.MatplotlibDeprecationWarning): + cm.register_cmap(name, mpl.colormaps[name], override_builtin=True) def test_unregister_builtin_cmap(): diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 515068c462d4..610b6056f20f 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 961daaa1d167..ff9a519ee185 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 +from packaging.version import parse as parse_version import numpy as np from numpy.testing import assert_almost_equal, assert_array_equal @@ -914,10 +915,17 @@ def test_mathtext_ticks(self): 'axes.formatter.use_mathtext': False }) - with pytest.warns(UserWarning, match='cmr10 font should ideally'): - fig, ax = plt.subplots() - ax.set_xticks([-1, 0, 1]) - fig.canvas.draw() + if parse_version(pytest.__version__).major < 8: + with pytest.warns(UserWarning, match='cmr10 font should ideally'): + fig, ax = plt.subplots() + ax.set_xticks([-1, 0, 1]) + fig.canvas.draw() + else: + with (pytest.warns(UserWarning, match="Glyph 8722"), + pytest.warns(UserWarning, match='cmr10 font should ideally')): + fig, ax = plt.subplots() + ax.set_xticks([-1, 0, 1]) + fig.canvas.draw() def test_cmr10_substitutions(self, caplog): mpl.rcParams.update({ 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