@@ -215,42 +215,42 @@ def test_load_setuptools_not_installed(monkeypatch, pm):
215
215
216
216
217
217
def test_add_tracefuncs (he_pm ):
218
- l = []
218
+ out = []
219
219
220
220
class api1 (object ):
221
221
@hookimpl
222
222
def he_method1 (self ):
223
- l .append ("he_method1-api1" )
223
+ out .append ("he_method1-api1" )
224
224
225
225
class api2 (object ):
226
226
@hookimpl
227
227
def he_method1 (self ):
228
- l .append ("he_method1-api2" )
228
+ out .append ("he_method1-api2" )
229
229
230
230
he_pm .register (api1 ())
231
231
he_pm .register (api2 ())
232
232
233
233
def before (hook_name , hook_impls , kwargs ):
234
- l .append ((hook_name , list (hook_impls ), kwargs ))
234
+ out .append ((hook_name , list (hook_impls ), kwargs ))
235
235
236
236
def after (outcome , hook_name , hook_impls , kwargs ):
237
- l .append ((outcome , hook_name , list (hook_impls ), kwargs ))
237
+ out .append ((outcome , hook_name , list (hook_impls ), kwargs ))
238
238
239
239
undo = he_pm .add_hookcall_monitoring (before , after )
240
240
241
241
he_pm .hook .he_method1 (arg = 1 )
242
- assert len (l ) == 4
243
- assert l [0 ][0 ] == "he_method1"
244
- assert len (l [0 ][1 ]) == 2
245
- assert isinstance (l [0 ][2 ], dict )
246
- assert l [1 ] == "he_method1-api2"
247
- assert l [2 ] == "he_method1-api1"
248
- assert len (l [3 ]) == 4
249
- assert l [3 ][1 ] == l [0 ][0 ]
242
+ assert len (out ) == 4
243
+ assert out [0 ][0 ] == "he_method1"
244
+ assert len (out [0 ][1 ]) == 2
245
+ assert isinstance (out [0 ][2 ], dict )
246
+ assert out [1 ] == "he_method1-api2"
247
+ assert out [2 ] == "he_method1-api1"
248
+ assert len (out [3 ]) == 4
249
+ assert out [3 ][1 ] == out [0 ][0 ]
250
250
251
251
undo ()
252
252
he_pm .hook .he_method1 (arg = 1 )
253
- assert len (l ) == 4 + 2
253
+ assert len (out ) == 4 + 2
254
254
255
255
256
256
def test_hook_tracing (he_pm ):
@@ -268,18 +268,18 @@ def he_method1(self):
268
268
raise ValueError ()
269
269
270
270
he_pm .register (api1 ())
271
- l = []
272
- he_pm .trace .root .setwriter (l .append )
271
+ out = []
272
+ he_pm .trace .root .setwriter (out .append )
273
273
undo = he_pm .enable_tracing ()
274
274
try :
275
275
indent = he_pm .trace .root .indent
276
276
he_pm .hook .he_method1 (arg = 1 )
277
277
assert indent == he_pm .trace .root .indent
278
- assert len (l ) == 2
279
- assert 'he_method1' in l [0 ]
280
- assert 'finish' in l [1 ]
278
+ assert len (out ) == 2
279
+ assert 'he_method1' in out [0 ]
280
+ assert 'finish' in out [1 ]
281
281
282
- l [:] = []
282
+ out [:] = []
283
283
he_pm .register (api2 ())
284
284
285
285
with pytest .raises (ValueError ):
@@ -290,15 +290,17 @@ def he_method1(self):
290
290
undo ()
291
291
292
292
293
- def test_prefix_hookimpl ():
293
+ @pytest .mark .parametrize ('include_hookspec' , [True , False ])
294
+ def test_prefix_hookimpl (include_hookspec ):
294
295
pm = PluginManager (hookspec .project_name , "hello_" )
295
296
296
- class HookSpec (object ):
297
- @hookspec
298
- def hello_myhook (self , arg1 ):
299
- """ add to arg1 """
297
+ if include_hookspec :
298
+ class HookSpec (object ):
299
+ @hookspec
300
+ def hello_myhook (self , arg1 ):
301
+ """ add to arg1 """
300
302
301
- pm .add_hookspecs (HookSpec )
303
+ pm .add_hookspecs (HookSpec )
302
304
303
305
class Plugin (object ):
304
306
def hello_myhook (self , arg1 ):
0 commit comments