From 48c18cbd11137223854fe0cb2fab5a5db534255b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 13 Dec 2020 23:25:03 +0100 Subject: [PATCH] Fix failing tests with pytest 6.2. ... per https://docs.pytest.org/en/stable/usage.html#unraisable. --- lib/matplotlib/tests/test_animation.py | 2 ++ lib/matplotlib/tests/test_image.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_animation.py b/lib/matplotlib/tests/test_animation.py index 2e6fef9ff3f4..b241b916cc0b 100644 --- a/lib/matplotlib/tests/test_animation.py +++ b/lib/matplotlib/tests/test_animation.py @@ -197,6 +197,8 @@ def test_animation_repr_html(writer, html, want, anim): html = anim._repr_html_() if want is None: assert html is None + with pytest.warns(UserWarning): + del anim # Animtion was never run, so will warn on cleanup. else: assert want in html diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 5ce4c6a6d843..00ba2552b5bb 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -707,7 +707,8 @@ def test_load_from_url(): + ('///' if sys.platform == 'win32' else '') + path.resolve().as_posix()) plt.imread(url) - plt.imread(urllib.request.urlopen(url)) + with urllib.request.urlopen(url) as file: + plt.imread(file) @image_comparison(['log_scale_image'], remove_text=True)