Skip to content

Commit 6ef9cce

Browse files
committed
improve test code
1 parent a62c25f commit 6ef9cce

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/matplotlib/tests/test_legend.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1452,10 +1452,8 @@ def test_boxplot_legend():
14521452
lbl_index += 1
14531453

14541454
legend = axs.legend()
1455-
index = 0
1456-
for i in legend.legend_handles:
1457-
assert isinstance(i, mpl.patches.Rectangle)
1458-
assert i.get_facecolor() == colors[index]
1459-
assert i.get_edgecolor() == colors[index]
1460-
assert i.get_label() == labels[index]
1461-
index += 1
1455+
for index, handle in enumerate(legend.legend_handles):
1456+
assert isinstance(handle, mpl.patches.Rectangle)
1457+
assert handle.get_facecolor() == colors[index]
1458+
assert handle.get_edgecolor() == colors[index]
1459+
assert handle.get_label() == labels[index]

0 commit comments

Comments
 (0)