Skip to content

Commit 349103f

Browse files
authored
Merge pull request #21851 from dstansby/widget-test-order
Re-order a widget test function
2 parents 40c77d3 + 22b2002 commit 349103f

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,46 +1232,6 @@ def onselect(vertices):
12321232
assert artist.get_alpha() == 0.3
12331233

12341234

1235-
@pytest.mark.parametrize(
1236-
"horizOn, vertOn",
1237-
[(True, True), (True, False), (False, True)],
1238-
)
1239-
def test_MultiCursor(horizOn, vertOn):
1240-
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
1241-
1242-
# useblit=false to avoid having to draw the figure to cache the renderer
1243-
multi = widgets.MultiCursor(
1244-
fig.canvas, (ax1, ax2), useblit=False, horizOn=horizOn, vertOn=vertOn
1245-
)
1246-
1247-
# Only two of the axes should have a line drawn on them.
1248-
if vertOn:
1249-
assert len(multi.vlines) == 2
1250-
if horizOn:
1251-
assert len(multi.hlines) == 2
1252-
1253-
# mock a motion_notify_event
1254-
# Can't use `do_event` as that helper requires the widget
1255-
# to have a single .ax attribute.
1256-
event = mock_event(ax1, xdata=.5, ydata=.25)
1257-
multi.onmove(event)
1258-
1259-
# the lines in the first two ax should both move
1260-
for l in multi.vlines:
1261-
assert l.get_xdata() == (.5, .5)
1262-
for l in multi.hlines:
1263-
assert l.get_ydata() == (.25, .25)
1264-
1265-
# test a move event in an axes not part of the MultiCursor
1266-
# the lines in ax1 and ax2 should not have moved.
1267-
event = mock_event(ax3, xdata=.75, ydata=.75)
1268-
multi.onmove(event)
1269-
for l in multi.vlines:
1270-
assert l.get_xdata() == (.5, .5)
1271-
for l in multi.hlines:
1272-
assert l.get_ydata() == (.25, .25)
1273-
1274-
12751235
@check_figures_equal()
12761236
def test_rect_visibility(fig_test, fig_ref):
12771237
# Check that requesting an invisible selector makes it invisible
@@ -1338,3 +1298,43 @@ def onselect(vertices):
13381298
# After removing two verts, only one remains, and the
13391299
# selector should be automatically resete
13401300
assert tool.verts == verts[0:2]
1301+
1302+
1303+
@pytest.mark.parametrize(
1304+
"horizOn, vertOn",
1305+
[(True, True), (True, False), (False, True)],
1306+
)
1307+
def test_MultiCursor(horizOn, vertOn):
1308+
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
1309+
1310+
# useblit=false to avoid having to draw the figure to cache the renderer
1311+
multi = widgets.MultiCursor(
1312+
fig.canvas, (ax1, ax2), useblit=False, horizOn=horizOn, vertOn=vertOn
1313+
)
1314+
1315+
# Only two of the axes should have a line drawn on them.
1316+
if vertOn:
1317+
assert len(multi.vlines) == 2
1318+
if horizOn:
1319+
assert len(multi.hlines) == 2
1320+
1321+
# mock a motion_notify_event
1322+
# Can't use `do_event` as that helper requires the widget
1323+
# to have a single .ax attribute.
1324+
event = mock_event(ax1, xdata=.5, ydata=.25)
1325+
multi.onmove(event)
1326+
1327+
# the lines in the first two ax should both move
1328+
for l in multi.vlines:
1329+
assert l.get_xdata() == (.5, .5)
1330+
for l in multi.hlines:
1331+
assert l.get_ydata() == (.25, .25)
1332+
1333+
# test a move event in an axes not part of the MultiCursor
1334+
# the lines in ax1 and ax2 should not have moved.
1335+
event = mock_event(ax3, xdata=.75, ydata=.75)
1336+
multi.onmove(event)
1337+
for l in multi.vlines:
1338+
assert l.get_xdata() == (.5, .5)
1339+
for l in multi.hlines:
1340+
assert l.get_ydata() == (.25, .25)

0 commit comments

Comments
 (0)