Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 324e651

Browse files
committed
Updated host + parasite axes picking tests.
1 parent 79643e5 commit 324e651

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import numpy as np
2121

22+
import pytest
23+
2224

2325
@image_comparison(baseline_images=['divider_append_axes'])
2426
def test_divider_append_axes():
@@ -181,22 +183,29 @@ class TestPickingCallbacksOverlap(object):
181183
# In each case we expect that both rectangles are picked if we click on the
182184
# small one and only the big one is picked if we click on the big one.
183185
# Also tests picking on normal axes ("gca") as a control.
184-
def setUp(self):
185-
self.q = six.Queue()
186+
187+
@pytest.fixture(autouse=True)
188+
def setup(self):
189+
self.q = six.moves.queue.Queue()
186190
self.big = plt.Rectangle((0.25, 0.25), 0.5, 0.5, picker=5)
187191
self.small = plt.Rectangle((0.4, 0.4), 0.2, 0.2, facecolor="r",
188192
picker=5)
189193
plt.gcf().canvas.mpl_connect('pick_event', self.on_pick)
194+
190195
def on_pick(self, event):
191196
self.q.put(event)
192-
def test_picking_simple(self):
193-
# Configurations here are of the form: ( big_on_axes, small_on_axes )
194-
for rectangles_on_axes in [ ("gca", "gca"), ("host", "host"),
195-
("host", "parasite"), ("parasite", "host"),
196-
("parasite", "parasite") ]:
197-
for click_on in [ "big", "small" ]:
198-
yield self.run, rectangles_on_axes, click_on
199-
def run(self, rectangles_on_axes, click_on):
197+
198+
@pytest.mark.parametrize("click_on", [ "big", "small" ])
199+
@pytest.mark.parametrize("big_on_axes,small_on_axes", [
200+
("gca", "gca"),
201+
("host", "host"),
202+
("host", "parasite"),
203+
("parasite", "host"),
204+
("parasite", "parasite")
205+
])
206+
def test_picking_simple(self, big_on_axes, small_on_axes, click_on):
207+
# Shortcut
208+
rectangles_on_axes = (big_on_axes, small_on_axes)
200209
# Axes setup
201210
axes = { "gca": None, "host": None, "parasite": None }
202211
if "gca" in rectangles_on_axes:
@@ -205,7 +214,6 @@ def run(self, rectangles_on_axes, click_on):
205214
axes["host"] = host_subplot(111)
206215
axes["parasite"] = axes["host"].twin()
207216
# Add rectangles to axes
208-
(big_on_axes, small_on_axes) = rectangles_on_axes
209217
axes[big_on_axes].add_patch(self.big)
210218
axes[small_on_axes].add_patch(self.small)
211219
# Simulate picking with click mouse event

0 commit comments

Comments
 (0)