MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_text_nohandler_warning

Function test_text_nohandler_warning

lib/matplotlib/tests/test_legend.py:642–656  ·  view source on GitHub ↗

Test that Text artists with labels raise a warning

()

Source from the content-addressed store, hash-verified

640
641
642def test_text_nohandler_warning():
643 """Test that Text artists with labels raise a warning"""
644 fig, ax = plt.subplots()
645 ax.plot([0], label="mock data")
646 ax.text(x=0, y=0, s="text", label="label")
647 with pytest.warns(UserWarning) as record:
648 ax.legend()
649 assert len(record) == 1
650
651 # this should _not_ warn:
652 f, ax = plt.subplots()
653 ax.pcolormesh(np.random.uniform(0, 1, (10, 10)))
654 with warnings.catch_warnings():
655 warnings.simplefilter("error")
656 ax.get_legend_handles_labels()
657
658
659def test_empty_bar_chart_with_legend():

Callers

nothing calls this directly

Calls 6

pcolormeshMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
textMethod · 0.45
legendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…