File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
1
from matplotlib import rcParams
2
2
from matplotlib import pyplot as plt
3
3
from matplotlib .testing .decorators import cleanup
4
+ from matplotlib ._pylab_helpers import Gcf
5
+ import copy
6
+
4
7
5
8
@cleanup
6
9
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 )
8
15
16
+ # make a figure using pyplot interface
9
17
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 )
You can’t perform that action at this time.
0 commit comments