19
19
20
20
import numpy as np
21
21
22
+ import pytest
23
+
22
24
23
25
@image_comparison (baseline_images = ['divider_append_axes' ])
24
26
def test_divider_append_axes ():
@@ -181,22 +183,29 @@ class TestPickingCallbacksOverlap(object):
181
183
# In each case we expect that both rectangles are picked if we click on the
182
184
# small one and only the big one is picked if we click on the big one.
183
185
# 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 ()
186
190
self .big = plt .Rectangle ((0.25 , 0.25 ), 0.5 , 0.5 , picker = 5 )
187
191
self .small = plt .Rectangle ((0.4 , 0.4 ), 0.2 , 0.2 , facecolor = "r" ,
188
192
picker = 5 )
189
193
plt .gcf ().canvas .mpl_connect ('pick_event' , self .on_pick )
194
+
190
195
def on_pick (self , event ):
191
196
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 )
200
209
# Axes setup
201
210
axes = { "gca" : None , "host" : None , "parasite" : None }
202
211
if "gca" in rectangles_on_axes :
@@ -205,7 +214,6 @@ def run(self, rectangles_on_axes, click_on):
205
214
axes ["host" ] = host_subplot (111 )
206
215
axes ["parasite" ] = axes ["host" ].twin ()
207
216
# Add rectangles to axes
208
- (big_on_axes , small_on_axes ) = rectangles_on_axes
209
217
axes [big_on_axes ].add_patch (self .big )
210
218
axes [small_on_axes ].add_patch (self .small )
211
219
# Simulate picking with click mouse event
0 commit comments