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

Skip to content

Commit e7f051f

Browse files
committed
TST: Added tests for remove of legends on figure and axes objects
1 parent fbcaec5 commit e7f051f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from six.moves import xrange
66

77
import mock
8-
from nose.tools import assert_equal
8+
from nose.tools import assert_equal, assert_is
99
import numpy as np
1010

1111
from matplotlib.testing.decorators import image_comparison, cleanup
@@ -113,6 +113,19 @@ def test_legend_expand():
113113
ax.legend(loc=3, mode=mode, ncol=2)
114114

115115

116+
@cleanup
117+
def test_legend_remove():
118+
fig = plt.figure()
119+
ax = fig.add_subplot(1, 1, 1)
120+
lines = ax.plot(range(10))
121+
leg = fig.legend(lines, "test")
122+
leg.remove()
123+
assert_equal(fig.legends, [])
124+
leg = ax.legend("test")
125+
leg.remove()
126+
assert_is(ax.get_legend(), None)
127+
128+
116129
class TestLegendFunction(object):
117130
# Tests the legend function on the Axes and pyplot.
118131

0 commit comments

Comments
 (0)