Skip to content

Commit f43c73b

Browse files
fix: Pass module spec via stdin instead of command line args (#4844)
Co-authored-by: Alison Hart <[email protected]>
1 parent d14f242 commit f43c73b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/ansiblelint/rules/args.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,16 @@ def matchtask(
194194
# through `ArgumentSpecValidator` class as in case of modules.
195195
return []
196196

197-
with patch.object(
198-
sys,
199-
"argv",
200-
["", json.dumps({"ANSIBLE_MODULE_ARGS": clean_json(module_args)})],
197+
buffer = io.BytesIO(
198+
json.dumps({
199+
"ANSIBLE_MODULE_ARGS": clean_json(module_args)
200+
}).encode()
201+
)
202+
with (
203+
patch.object(
204+
sys, "stdin", io.TextIOWrapper(buffer, encoding="utf-8")
205+
),
206+
patch.object(sys, "argv", [""]),
201207
):
202208
fio = io.StringIO()
203209
failed_msg = ""

0 commit comments

Comments
 (0)