@@ -218,29 +218,30 @@ async def test_nanny_plugin_with_broken_teardown_logs_on_close(c, s):
218218 assert "TestPlugin1 failed to teardown" in logs
219219 assert "test error" in logs
220220
221+
221222@gen_cluster (client = True , nthreads = [("" , 1 )], Worker = Nanny )
222223async def test_has_nanny_plugin_by_name (c , s , a ):
223224 """Test checking if nanny plugin is registered using string name"""
224-
225+
225226 class DuckPlugin (NannyPlugin ):
226227 name = "duck-plugin"
227-
228+
228229 def setup (self , nanny ):
229230 nanny .foo = 123
230-
231+
231232 def teardown (self , nanny ):
232233 pass
233-
234+
234235 # Check non-existent plugin
235236 assert not await c .has_plugin ("duck-plugin" )
236-
237+
237238 # Register plugin
238239 await c .register_plugin (DuckPlugin ())
239240 assert a .foo == 123
240-
241+
241242 # Check using string name
242243 assert await c .has_plugin ("duck-plugin" )
243-
244+
244245 # Unregister and check again
245246 await c .unregister_worker_plugin ("duck-plugin" , nanny = True )
246247 assert not await c .has_plugin ("duck-plugin" )
@@ -249,26 +250,26 @@ def teardown(self, nanny):
249250@gen_cluster (client = True , nthreads = [("" , 1 )], Worker = Nanny )
250251async def test_has_nanny_plugin_by_object (c , s , a ):
251252 """Test checking if nanny plugin is registered using plugin object"""
252-
253+
253254 class DuckPlugin (NannyPlugin ):
254255 name = "duck-plugin"
255-
256+
256257 def setup (self , nanny ):
257258 nanny .bar = 456
258-
259+
259260 def teardown (self , nanny ):
260261 pass
261-
262+
262263 plugin = DuckPlugin ()
263-
264+
264265 # Check before registration
265266 assert not await c .has_plugin (plugin )
266-
267+
267268 # Register and check
268269 await c .register_plugin (plugin )
269270 assert a .bar == 456
270271 assert await c .has_plugin (plugin )
271-
272+
272273 # Unregister and check
273274 await c .unregister_worker_plugin ("duck-plugin" , nanny = True )
274275 assert not await c .has_plugin (plugin )
@@ -277,89 +278,92 @@ def teardown(self, nanny):
277278@gen_cluster (client = True , nthreads = [("" , 1 ), ("" , 1 )], Worker = Nanny )
278279async def test_has_nanny_plugin_multiple_nannies (c , s , a , b ):
279280 """Test checking nanny plugin with multiple nannies"""
280-
281+
281282 class DuckPlugin (NannyPlugin ):
282283 name = "duck-plugin"
283-
284+
284285 def setup (self , nanny ):
285286 nanny .multi = "setup"
286-
287+
287288 def teardown (self , nanny ):
288289 pass
289-
290+
290291 # Check before registration
291292 assert not await c .has_plugin ("duck-plugin" )
292-
293+
293294 # Register plugin (should propagate to all nannies)
294295 await c .register_plugin (DuckPlugin ())
295-
296+
296297 # Verify both nannies have the plugin
297298 assert a .multi == "setup"
298299 assert b .multi == "setup"
299-
300+
300301 # Check plugin is registered
301302 assert await c .has_plugin ("duck-plugin" )
302303
304+
303305@gen_cluster (client = True , nthreads = [("" , 1 )], Worker = Nanny )
304306async def test_has_nanny_plugin_custom_name_override (c , s , a ):
305307 """Test nanny plugin registered with custom name different from class name"""
306-
308+
307309 class DuckPlugin (NannyPlugin ):
308310 name = "duck-plugin"
309-
311+
310312 def setup (self , nanny ):
311313 nanny .custom = "test"
312-
314+
313315 def teardown (self , nanny ):
314316 pass
315-
317+
316318 plugin = DuckPlugin ()
317-
319+
318320 # Register with custom name (overriding the class name attribute)
319321 await c .register_plugin (plugin , name = "custom-override" )
320-
322+
321323 # Check with custom name works
322324 assert await c .has_plugin ("custom-override" )
323-
325+
324326 # Original name won't work since we overrode it
325327 assert not await c .has_plugin ("duck-plugin" )
326328
327329
328330@gen_cluster (client = True , nthreads = [("" , 1 )], Worker = Nanny )
329331async def test_has_nanny_plugin_list_check (c , s , a ):
330332 """Test checking multiple nanny plugins at once"""
331-
333+
332334 class IdempotentPlugin (NannyPlugin ):
333335 name = "idempotentplugin"
334-
336+
335337 def setup (self , nanny ):
336338 pass
337-
339+
338340 def teardown (self , nanny ):
339341 pass
340-
342+
341343 class NonIdempotentPlugin (NannyPlugin ):
342344 name = "nonidempotentplugin"
343-
345+
344346 def setup (self , nanny ):
345347 pass
346-
348+
347349 def teardown (self , nanny ):
348350 pass
349-
351+
350352 # Check multiple before registration
351- result = await c .has_plugin (["idempotentplugin" , "nonidempotentplugin" , "nonexistent" ])
353+ result = await c .has_plugin (
354+ ["idempotentplugin" , "nonidempotentplugin" , "nonexistent" ]
355+ )
352356 assert result == {
353357 "idempotentplugin" : False ,
354358 "nonidempotentplugin" : False ,
355359 "nonexistent" : False ,
356360 }
357-
361+
358362 # Register first plugin
359363 await c .register_plugin (IdempotentPlugin ())
360364 result = await c .has_plugin (["idempotentplugin" , "nonidempotentplugin" ])
361365 assert result == {"idempotentplugin" : True , "nonidempotentplugin" : False }
362-
366+
363367 # Register second plugin
364368 await c .register_plugin (NonIdempotentPlugin ())
365369 result = await c .has_plugin (["idempotentplugin" , "nonidempotentplugin" ])
0 commit comments