8000 New check for the no len case. Now artists are stored · matplotlib/matplotlib@27413fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 27413fa

Browse files
committed
New check for the no len case. Now artists are stored
1 parent ded6000 commit 27413fa

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,18 @@ def test_loc_validation_string_value():
13601360

13611361

13621362
def test_legend_handle_label_mismatch():
1363-
pl1 = plt.plot(range(10))
1364-
pl2 = plt.plot(range(10))
1363+
pl1, = plt.plot(range(10))
1364+
pl2, = plt.plot(range(10))
13651365
with pytest.warns(UserWarning, match="number of handles and labels"):
1366-
plt.legend(handles=[pl1, pl2], labels=["pl1", "pl2", "pl3"])
1366+
legend = plt.legend(handles=[pl1, pl2], labels=["pl1", "pl2", "pl3"])
1367+
assert len(legend.legend_handles) == 2
1368+
assert len(legend.get_texts()) == 2
1369+
1370+
1371+
def test_legend_handle_label_mismatch_no_len():
1372+
pl1, = plt.plot(range(10))
1373+
pl2, = plt.plot(range(10))
1374+
legend = plt.legend(handles=iter([pl1, pl2]),
1375+
labels=iter(["pl1", "pl2", "pl3"]))
1376+
assert len(legend.legend_handles) == 2
1377+
assert len(legend.get_texts()) == 2

0 commit comments

Comments
 (0)
0