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

Skip to content

Commit 090b6d6

Browse files
committed
TST: added test of remove functionality
1 parent 01c4b90 commit 090b6d6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/matplotlib/tests/test_artist.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import matplotlib.collections as mcollections
1515
from matplotlib.testing.decorators import image_comparison, cleanup
1616

17+
from nose.tools import (assert_true, assert_false, assert_is, assert_in,
18+
assert_not_in)
19+
1720

1821
@cleanup
1922
def test_patch_transform_of_none():
@@ -144,6 +147,30 @@ def test_cull_markers():
144147
assert len(svg.getvalue()) < 20000
145148

146149

150+
@cleanup
151+
def test_remove():
152+
fig, ax = plt.subplots()
153+
im = ax.imshow(np.arange(36).reshape(6, 6))
154+
155+
assert_true(fig.stale)
156+
assert_true(ax.stale)
157+
158+
fig.canvas.draw()
159+
assert_false(fig.stale)
160+
assert_false(ax.stale)
161+
162+
assert_in(im, ax.mouseover_set)
163+
assert_is(im.axes, ax)
164+
165+
im.remove()
166+
167+
assert_is(im.axes, None)
168+
assert_is(im.figure, None)
169+
assert_not_in(im, ax.mouseover_set)
170+
assert_true(fig.stale)
171+
assert_true(ax.stale)
172+
173+
147174
if __name__ == '__main__':
148175
import nose
149176
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)