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)