|
3 | 3 | import operator
|
4 | 4 | from unittest import mock
|
5 | 5 |
|
6 |
| -from matplotlib.backend_bases import MouseEvent |
| 6 | +from matplotlib.backend_bases import MouseEvent, DrawEvent |
7 | 7 | import matplotlib.colors as mcolors
|
8 | 8 | import matplotlib.widgets as widgets
|
9 | 9 | import matplotlib.pyplot as plt
|
@@ -1757,3 +1757,26 @@ def test_MultiCursor(horizOn, vertOn):
|
1757 | 1757 | assert l.get_xdata() == (.5, .5)
|
1758 | 1758 | for l in multi.hlines:
|
1759 | 1759 | assert l.get_ydata() == (.25, .25)
|
| 1760 | + |
| 1761 | + |
| 1762 | +def test_parent_axes_removal(): |
| 1763 | + |
| 1764 | + fig, (ax_radio, ax_checks) = plt.subplots(1, 2) |
| 1765 | + |
| 1766 | + radio = widgets.RadioButtons(ax_radio, ['1', '2'], 0) |
| 1767 | + checks = widgets.CheckButtons(ax_checks, ['1', '2'], [True, False]) |
| 1768 | + |
| 1769 | + ax_checks.remove() |
| 1770 | + ax_radio.remove() |
| 1771 | + with io.BytesIO() as out: |
| 1772 | + # verify that saving does not raise |
| 1773 | + fig.savefig(out, format='raw') |
| 1774 | + |
| 1775 | + # verify that this method which is triggered by a draw_event callback when |
| 1776 | + # blitting is enabled does not raise. Calling private methods is simpler |
| 1777 | + # than trying to force blitting to be enabled with Agg or use a GUI |
| 1778 | + # framework. |
| 1779 | + renderer = fig._get_renderer() |
| 1780 | + evt = DrawEvent('draw_event', fig.canvas, renderer) |
| 1781 | + radio._clear(evt) |
| 1782 | + checks._clear(evt) |
0 commit comments