From 75498742e93652112b0d43a89c98e984a39b6a7f Mon Sep 17 00:00:00 2001 From: MarcoGorelli Date: Sat, 2 Nov 2019 11:09:58 +0000 Subject: [PATCH] Make sure that figures are closed when check_figures_equal finishes --- lib/matplotlib/testing/decorators.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index 7e9621cb3b1d..c258574dca11 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -389,18 +389,22 @@ def decorator(func): @pytest.mark.parametrize("ext", extensions) def wrapper(*args, ext, **kwargs): - fig_test = plt.figure("test") - fig_ref = plt.figure("reference") - func(*args, fig_test=fig_test, fig_ref=fig_ref, **kwargs) - test_image_path = result_dir / (func.__name__ + "." + ext) - ref_image_path = result_dir / ( - func.__name__ + "-expected." + ext - ) - fig_test.savefig(test_image_path) - fig_ref.savefig(ref_image_path) - _raise_on_image_difference( - ref_image_path, test_image_path, tol=tol - ) + try: + fig_test = plt.figure("test") + fig_ref = plt.figure("reference") + func(*args, fig_test=fig_test, fig_ref=fig_ref, **kwargs) + test_image_path = result_dir / (func.__name__ + "." + ext) + ref_image_path = result_dir / ( + func.__name__ + "-expected." + ext + ) + fig_test.savefig(test_image_path) + fig_ref.savefig(ref_image_path) + _raise_on_image_difference( + ref_image_path, test_image_path, tol=tol + ) + finally: + plt.close(fig_test) + plt.close(fig_ref) sig = inspect.signature(func) new_sig = sig.replace( 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