diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index 7cb5af621450..4c688eb05b15 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -365,8 +365,8 @@ def test_subplots_shareax_loglabels(): def test_savefig(): fig = plt.figure() - msg = "savefig() takes 2 positional arguments but 3 were given" - with pytest.raises(TypeError, message=msg): + msg = r"savefig\(\) takes 2 positional arguments but 3 were given" + with pytest.raises(TypeError, match=msg): fig.savefig("fname1.png", "fname2.png")