|
| 1 | +from matplotlib._api.deprecation import MatplotlibDeprecationWarning |
1 | 2 | import matplotlib.colors as mcolors |
2 | 3 | import matplotlib.widgets as widgets |
3 | 4 | import matplotlib.pyplot as plt |
4 | | -from matplotlib.testing.decorators import image_comparison |
| 5 | +from matplotlib.testing.decorators import check_figures_equal, image_comparison |
5 | 6 | from matplotlib.testing.widgets import do_event, get_ax, mock_event |
6 | 7 |
|
7 | 8 | from numpy.testing import assert_allclose |
@@ -37,9 +38,19 @@ def onselect(epress, erelease): |
37 | 38 |
|
38 | 39 | def test_rectangle_selector(): |
39 | 40 | check_rectangle() |
40 | | - check_rectangle(drawtype='line', useblit=False) |
| 41 | + |
| 42 | + with pytest.warns( |
| 43 | + MatplotlibDeprecationWarning, |
| 44 | + match="Support for drawtype='line' is deprecated"): |
| 45 | + check_rectangle(drawtype='line', useblit=False) |
| 46 | + |
41 | 47 | check_rectangle(useblit=True, button=1) |
42 | | - check_rectangle(drawtype='none', minspanx=10, minspany=10) |
| 48 | + |
| 49 | + with pytest.warns( |
| 50 | + MatplotlibDeprecationWarning, |
| 51 | + match="Support for drawtype='none' is deprecated"): |
| 52 | + check_rectangle(drawtype='none', minspanx=10, minspany=10) |
| 53 | + |
43 | 54 | check_rectangle(minspanx=10, minspany=10, spancoords='pixels') |
44 | 55 | check_rectangle(rectprops=dict(fill=True)) |
45 | 56 |
|
@@ -500,3 +511,17 @@ def test_MultiCursor(horizOn, vertOn): |
500 | 511 | assert l.get_xdata() == (.5, .5) |
501 | 512 | for l in multi.hlines: |
502 | 513 | assert l.get_ydata() == (.25, .25) |
| 514 | + |
| 515 | + |
| 516 | +@check_figures_equal() |
| 517 | +def test_rect_visibility(fig_test, fig_ref): |
| 518 | + # Check that requesting an invisible selector makes it invisible |
| 519 | + ax_test = fig_test.subplots() |
| 520 | + ax_ref = fig_ref.subplots() |
| 521 | + |
| 522 | + def onselect(verts): |
| 523 | + pass |
| 524 | + |
| 525 | + tool = widgets.RectangleSelector(ax_test, onselect, |
| 526 | + rectprops={'visible': False}) |
| 527 | + tool.extents = (0.2, 0.8, 0.3, 0.7) |
0 commit comments