[PR #9666/c0f57b5c backport][stable-10] test helper: add support for check and diff modes (#9669)

test helper: add support for check and diff modes (#9666)

(cherry picked from commit c0f57b5c62)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot]
2025-02-01 18:49:35 +01:00
committed by GitHub
parent 4d4e626f95
commit c35f13084d
2 changed files with 47 additions and 7 deletions

View File

@@ -72,7 +72,13 @@ class Helper(object):
"""
Run unit tests for each test case in self.test_cases
"""
patch_ansible_module(test_case.input)
args = {}
args.update(test_case.input)
if test_case.flags.get("check"):
args["_ansible_check_mode"] = test_case.flags.get("check")
if test_case.flags.get("diff"):
args["_ansible_diff"] = test_case.flags.get("diff")
patch_ansible_module(args)
self.runner.run(mocker, capfd, test_case)
self.add_func_to_test_module("test_module", _test_module)