Avoid delattr in test callback plugin (#82550)

This prevents the test plugin from tampering with the base callback plugin,
which causes issues with all other callback plugins running in the test.
pull/82551/head
Matt Clay 4 months ago committed by GitHub
parent b8c7ed39e4
commit 5f1b3898e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3,6 +3,8 @@
from __future__ import annotations
import functools
from ansible.plugins.callback import CallbackBase
@ -15,9 +17,8 @@ class CallbackModule(CallbackBase):
super(CallbackModule, self).__init__(*args, **kwargs)
self._display.display('__init__')
for cb in [x for x in dir(CallbackBase) if x.startswith('v2_')]:
delattr(CallbackBase, cb)
for name in (cb for cb in dir(self) if cb.startswith('v2_')):
setattr(self, name, functools.partial(self.handle_v2, name))
def __getattr__(self, name):
if name.startswith('v2_'):
return lambda *args, **kwargs: self._display.display(name)
def handle_v2(self, name, *args, **kwargs):
self._display.display(name)

Loading…
Cancel
Save