Skip to content

Commit 9eb04a6

Browse files
author
Chris
committed
Add test: show() closes figures when matplotlib has no pyplot attribute (#24)
1 parent 28f8f3a commit 9eb04a6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎tests/test_import.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,17 @@ def test_import():
22
from matplotlib_inline.backend_inline import show
33

44
show()
5+
6+
7+
def test_show_closes_figures_without_pyplot_attribute(monkeypatch):
8+
# gh-24: lazy loaders (e.g. librosa < 0.10.1) can leave matplotlib.pyplot
9+
# in sys.modules without setting it as an attribute of matplotlib.
10+
import matplotlib
11+
import matplotlib.pyplot as plt
12+
13+
from matplotlib_inline.backend_inline import show
14+
15+
plt.figure()
16+
monkeypatch.delattr(matplotlib, "pyplot")
17+
show(close=True)
18+
assert plt.get_fignums() == []

0 commit comments

Comments
 (0)