Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75a92df

Browse files
committed
test for issue matplotlib#1683
1 parent 3d3f8c3 commit 75a92df

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
from matplotlib import rcParams
22
from matplotlib import pyplot as plt
33
from matplotlib.testing.decorators import cleanup
4+
from matplotlib._pylab_helpers import Gcf
5+
import copy
6+
47

58
@cleanup
69
def test_fig_close():
7-
rcParams['backend'] = 'qt4agg'
10+
# force switch to the Qt4 backend
11+
plt.switch_backend('Qt4Agg')
12+
13+
#save the state of Gcf.figs
14+
init_figs = copy.copy(Gcf.figs)
815

16+
# make a figure using pyplot interface
917
fig = plt.figure()
10-
fig.close()
18+
19+
# simulate user clicking the close button by reaching in
20+
# and calling close on the underlying Qt object
21+
fig.canvas.manager.window.close()
22+
23+
# assert that we have removed the reference to the FigureManager
24+
# that got added by plt.figure()
25+
assert(init_figs == Gcf.figs)

0 commit comments

Comments
 (0)