mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Include stdout in error message
This commit is contained in:
parent
aadaf0bedd
commit
52c0b50592
2 changed files with 16 additions and 6 deletions
|
@ -294,7 +294,8 @@ class _Zypper:
|
|||
self.__call_result["stderr"]
|
||||
and self.__call_result["stderr"].strip()
|
||||
or ""
|
||||
) or (
|
||||
)
|
||||
msg += (
|
||||
self.__call_result["stdout"]
|
||||
and self.__call_result["stdout"].strip()
|
||||
or ""
|
||||
|
|
|
@ -203,17 +203,26 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
):
|
||||
zypper.__zypper__.xml.call("crashme")
|
||||
|
||||
output_to_user = "Output to user"
|
||||
sniffer = RunSniffer(stdout=output_to_user, retcode=1)
|
||||
with patch.dict("salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}):
|
||||
output_to_user_stdout = "Output to user to stdout"
|
||||
output_to_user_stderr = "Output to user to stderr"
|
||||
sniffer = RunSniffer(
|
||||
stdout=output_to_user_stdout, stderr=output_to_user_stderr, retcode=1
|
||||
)
|
||||
with patch.dict(
|
||||
"salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}
|
||||
), patch.object(zypper.__zypper__, "_is_rpm_lock", return_value=False):
|
||||
with self.assertRaisesRegex(
|
||||
CommandExecutionError,
|
||||
"^Zypper command failure: {}$".format(output_to_user),
|
||||
"^Zypper command failure: {}$".format(
|
||||
output_to_user_stderr + output_to_user_stdout
|
||||
),
|
||||
):
|
||||
zypper.__zypper__.call("crashme again")
|
||||
|
||||
sniffer = RunSniffer(retcode=1)
|
||||
with patch.dict("salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}):
|
||||
with patch.dict(
|
||||
"salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}
|
||||
), patch.object(zypper.__zypper__, "_is_rpm_lock", return_value=False):
|
||||
zypper.__zypper__.noraise.call("stay quiet")
|
||||
self.assertEqual(zypper.__zypper__.error_msg, "Check Zypper's logs.")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue