File tree 1 file changed +11
-3
lines changed
tests/unit/plugins/modules
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,17 @@ def set_module_args(args):
21
21
if '_ansible_keep_remote_files' not in args :
22
22
args ['_ansible_keep_remote_files' ] = False
23
23
24
- serialized_args = to_bytes (json .dumps ({'ANSIBLE_MODULE_ARGS' : args }))
25
- with patch .object (basic , '_ANSIBLE_ARGS' , serialized_args ):
26
- yield
24
+ try :
25
+ from ansible .module_utils .testing import patch_module_args
26
+ except ImportError :
27
+ # Before data tagging support was merged, this was the way to go:
28
+ serialized_args = to_bytes (json .dumps ({'ANSIBLE_MODULE_ARGS' : args }))
29
+ with patch .object (basic , '_ANSIBLE_ARGS' , serialized_args ):
30
+ yield
31
+ else :
32
+ # With data tagging support, we have a new helper for this:
33
+ with patch_module_args (args ):
34
+ yield
27
35
28
36
29
37
class AnsibleExitJson (Exception ):
You can’t perform that action at this time.
0 commit comments