8000 Added tests · matplotlib/matplotlib@7d43704 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d43704

Browse files
committed
Added tests
1 parent 46a102d commit 7d43704

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import matplotlib.legend as mlegend
1515
from matplotlib import rc_context
1616
from matplotlib.font_manager import FontProperties
17+
from matplotlib.patches import Ellipse
1718

1819

1920
def test_legend_ordereddict():
@@ -492,6 +493,25 @@ def test_handler_numpoints():
492493
ax.legend(numpoints=0.5)
493494

494495

496+
def test_ellipse_nohandler_warning():
497+
"""Test that Ellipse artists with labels raise a warning"""
498+
fig, ax = plt.subplots()
499+
ellip = Ellipse(xy=(0, 0), width=1, height=1, label="ellipse")
500+
ax.add_patch(ellip)
501+
with pytest.warns(UserWarning) as record:
502+
ax.legend()
503+
assert len(record) == 1
504+
505+
506+
def test_text_nohandler_warning():
507+
"""Test that Text artists with labels raise a warning"""
508+
fig, ax = plt.subplots()
509+
ax.text(x=0, y=0, s="text", label="label")
510+
with pytest.warns(UserWarning) as record:
511+
ax.legend()
512+
assert len(record) == 1
513+
514+
495515
def test_empty_bar_chart_with_legend():
496516
"""Test legend when bar chart is empty with a label."""
497517
# related to issue #13003. Calling plt.legend() should not

0 commit comments

Comments
 (0)
0