summaryrefslogtreecommitdiff
path: root/test/lib/ansible_test/_internal/util_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/ansible_test/_internal/util_common.py')
-rw-r--r--test/lib/ansible_test/_internal/util_common.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/lib/ansible_test/_internal/util_common.py b/test/lib/ansible_test/_internal/util_common.py
index 222366e4..77a6165c 100644
--- a/test/lib/ansible_test/_internal/util_common.py
+++ b/test/lib/ansible_test/_internal/util_common.py
@@ -88,7 +88,7 @@ class ExitHandler:
try:
func(*args, **kwargs)
- except BaseException as ex: # pylint: disable=broad-except
+ except BaseException as ex: # pylint: disable=broad-exception-caught
last_exception = ex
display.fatal(f'Exit handler failed: {ex}')
@@ -498,9 +498,14 @@ def run_command(
)
-def yamlcheck(python: PythonConfig) -> t.Optional[bool]:
+def yamlcheck(python: PythonConfig, explain: bool = False) -> t.Optional[bool]:
"""Return True if PyYAML has libyaml support, False if it does not and None if it was not found."""
- result = json.loads(raw_command([python.path, os.path.join(ANSIBLE_TEST_TARGET_TOOLS_ROOT, 'yamlcheck.py')], capture=True)[0])
+ stdout = raw_command([python.path, os.path.join(ANSIBLE_TEST_TARGET_TOOLS_ROOT, 'yamlcheck.py')], capture=True, explain=explain)[0]
+
+ if explain:
+ return None
+
+ result = json.loads(stdout)
if not result['yaml']:
return None