@@ -122,11 +122,6 @@ def test_default_units(self):
122
122
assert isinstance (self .cc .default_units (["a" ], self .ax ), cat .UnitData )
123
123
124
124
125
- @pytest .fixture
126
- def ax ():
127
- return plt .figure ().subplots ()
128
-
129
-
130
125
PLOT_LIST = [Axes .scatter , Axes .plot , Axes .bar ]
131
126
PLOT_IDS = ["scatter" , "plot" , "bar" ]
132
127
@@ -139,7 +134,8 @@ def test_StrCategoryLocator(self):
139
134
np .testing .assert_array_equal (ticks .tick_values (None , None ), locs )
140
135
141
136
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
142
- def test_StrCategoryLocatorPlot (self , ax , plotter ):
137
+ def test_StrCategoryLocatorPlot (self , plotter ):
138
+ ax = plt .figure ().subplots ()
143
139
plotter (ax , [1 , 2 , 3 ], ["a" , "b" , "c" ])
144
140
np .testing .assert_array_equal (ax .yaxis .major .locator (), range (3 ))
145
141
@@ -151,7 +147,7 @@ class TestStrCategoryFormatter:
151
147
ids , cases = zip (* test_cases )
152
148
153
149
@pytest .mark .parametrize ("ydata" , cases , ids = ids )
154
- def test_StrCategoryFormatter (self , ax , ydata ):
150
+ def test_StrCategoryFormatter (self , ydata ):
155
151
unit = cat .UnitData (ydata )
156
152
labels = cat .StrCategoryFormatter (unit ._mapping )
157
153
for i , d in enumerate (ydata ):
@@ -160,7 +156,8 @@ def test_StrCategoryFormatter(self, ax, ydata):
160
156
161
157
@pytest .mark .parametrize ("ydata" , cases , ids = ids )
162
158
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
163
- def test_StrCategoryFormatterPlot (self , ax , ydata , plotter ):
159
+ def test_StrCategoryFormatterPlot (self , ydata , plotter ):
160
+ ax = plt .figure ().subplots ()
164
161
plotter (ax , range (len (ydata )), ydata )
165
162
for i , d in enumerate (ydata ):
166
163
assert ax .yaxis .major .formatter (i ) == d
@@ -186,7 +183,8 @@ class TestPlotBytes:
186
183
187
184
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
188
185
@pytest .mark .parametrize ("bdata" , bytes_data , ids = bytes_ids )
189
- def test_plot_bytes (self , ax , plotter , bdata ):
186
+ def test_plot_bytes (self , plotter , bdata ):
187
+ ax = plt .figure ().subplots ()
190
188
counts = np .array ([4 , 6 , 5 ])
191
189
plotter (ax , bdata , counts )
192
190
axis_test (ax .xaxis , bdata )
@@ -201,15 +199,17 @@ class TestPlotNumlike:
201
199
202
200
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
203
201
@pytest .mark .parametrize ("ndata" , numlike_data , ids = numlike_ids )
204
- def test_plot_numlike (self , ax , plotter , ndata ):
202
+ def test_plot_numlike (self , plotter , ndata ):
203
+ ax = plt .figure ().subplots ()
205
204
counts = np .array ([4 , 6 , 5 ])
206
205
plotter (ax , ndata , counts )
207
206
axis_test (ax .xaxis , ndata )
208
207
209
208
210
209
class TestPlotTypes :
211
210
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
212
- def test_plot_unicode (self , ax , plotter ):
211
+ def test_plot_unicode (self , plotter ):
212
+ ax = plt .figure ().subplots ()
213
213
words = ['Здравствуйте' , 'привет' ]
214
214
plotter (ax , words , [0 , 1 ])
215
215
axis_test (ax .xaxis , words )
@@ -223,25 +223,29 @@ def test_data(self):
223
223
224
224
@pytest .mark .usefixtures ("test_data" )
225
225
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
226
- def test_plot_xaxis (self , ax , test_data , plotter ):
226
+ def test_plot_xaxis (self , test_data , plotter ):
227
+ ax = plt .figure ().subplots ()
227
228
plotter (ax , self .x , self .xy )
228
229
axis_test (ax .xaxis , self .x )
229
230
230
231
@pytest .mark .usefixtures ("test_data" )
231
232
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
232
- def test_plot_yaxis (self , ax , test_data , plotter ):
233
+ def test_plot_yaxis (self , test_data , plotter ):
234
+ ax = plt .figure ().subplots ()
233
235
plotter (ax , self .yx , self .y )
234
236
axis_test (ax .yaxis , self .y )
235
237
236
238
@pytest .mark .usefixtures ("test_data" )
237
239
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
238
- def test_plot_xyaxis (self , ax , test_data , plotter ):
240
+ def test_plot_xyaxis (self , test_data , plotter ):
241
+ ax = plt .figure ().subplots ()
239
242
plotter (ax , self .x , self .y )
240
243
axis_test (ax .xaxis , self .x )
241
244
axis_test (ax .yaxis , self .y )
242
245
243
246
@pytest .mark .parametrize ("plotter" , PLOT_LIST , ids = PLOT_IDS )
244
- def test_update_plot (self , ax , plotter ):
247
+ def test_update_plot (self , plotter ):
248
+ ax = plt .figure ().subplots ()
245
249
plotter (ax , ['a' , 'b' ], ['e' , 'g' ])
246
250
plotter (ax , ['a' , 'b' , 'd' ], ['f' , 'a' , 'b' ])
247
251
plotter (ax , ['b' , 'c' , 'd' ], ['g' , 'e' , 'd' ])
@@ -260,13 +264,15 @@ def test_update_plot(self, ax, plotter):
260
264
261
265
@pytest .mark .parametrize ("plotter" , plotters )
262
266
@pytest .mark .parametrize ("xdata" , fvalues , ids = fids )
263
- def test_mixed_type_exception (self , ax , plotter , xdata ):
267
+ def test_mixed_type_exception (self , plotter , xdata ):
268
+ ax = plt .figure ().subplots ()
264
269
with pytest .raises (TypeError ):
265
270
plotter (ax , xdata , [1 , 2 ])
266
271
267
272
@pytest .mark .parametrize ("plotter" , plotters )
268
273
@pytest .mark .parametrize ("xdata" , fvalues , ids = fids )
269
- def test_mixed_type_update_exception (self , ax , plotter , xdata ):
274
+ def test_mixed_type_update_exception (self , plotter , xdata ):
275
+ ax = plt .figure ().subplots ()
270
276
with pytest .raises (TypeError ):
271
277
plotter (ax , [0 , 3 ], [1 , 3 ])
272
278
plotter (ax , xdata , [1 , 2 ])
0 commit comments