forked from matplotlib/matplotlib
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |