From 75a92df91a059f87fe3be956adef44765346c9e2 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 19 Jan 2013 15:04:21 -0600 Subject: [PATCH] test for issue #1683 --- lib/matplotlib/tests/test_backend_qt4.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_backend_qt4.py b/lib/matplotlib/tests/test_backend_qt4.py index 81175d51b16a..9c551acb0f92 100644 --- a/lib/matplotlib/tests/test_backend_qt4.py +++ b/lib/matplotlib/tests/test_backend_qt4.py @@ -1,10 +1,25 @@ from matplotlib import rcParams from matplotlib import pyplot as plt from matplotlib.testing.decorators import cleanup +from matplotlib._pylab_helpers import Gcf +import copy + @cleanup def test_fig_close(): - rcParams['backend'] = 'qt4agg' + # force switch to the Qt4 backend + plt.switch_backend('Qt4Agg') + + #save the state of Gcf.figs + init_figs = copy.copy(Gcf.figs) + # make a figure using pyplot interface fig = plt.figure() - fig.close() + + # simulate user clicking the close button by reaching in + # and calling close on the underlying Qt object + fig.canvas.manager.window.close() + + # assert that we have removed the reference to the FigureManager + # that got added by plt.figure() + assert(init_figs == Gcf.figs)