8000 add basic tests for Legend draggable flag · matplotlib/matplotlib@6a82c9e · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a82c9e

Browse files
committed
add basic tests for Legend draggable flag
1 parent 3703788 commit 6a82c9e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import matplotlib.collections as mcollections
1313
from matplotlib.legend_handler import HandlerTuple
1414
import matplotlib.legend as mlegend
15+
from matplotlib.cbook.deprecation import MatplotlibDeprecationWarning
1516

1617

1718
def test_legend_ordereddict():
@@ -511,3 +512,30 @@ def test_legend_title_fontsize():
511512
ax.plot(range(10))
512513
leg = ax.legend(title='Aardvark', title_fontsize=22)
513514
assert leg.get_title().get_fontsize() == 22
515+
516+
517+
def test_get_set_draggable():
518+
legend = plt.legend()
519+
assert not legend.get_draggable()
520+
legend.set_draggable(True)
521+
assert legend.get_draggable()
522+
legend.set_draggable(False)
523+
assert not legend.get_draggable()
524+
525+
526+
def test_draggable():
527+
legend = plt.legend()
528+
with pytest.warns(MatplotlibDeprecationWarning):
529+
legend.draggable(True)
530+
assert legend.get_draggable()
531+
with pytest.warns(MatplotlibDeprecationWarning):
532+
legend.draggable(False)
533+
assert not legend.get_draggable()
534+
535+
# test toggle
536+
with pytest.warns(MatplotlibDeprecationWarning):
537+
legend.draggable()
538+
assert legend.get_draggable()
539+
with pytest.warns(MatplotlibDeprecationWarning):
540+
legend.draggable()
541+
assert not legend.get_draggable()

0 commit comments

Comments
 (0)
0