From 42ec8c98c7b013682f96d3b0558634772847ae0b Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Thu, 7 Dec 2017 11:07:58 +0100 Subject: [PATCH] Fixed and simplified invocation of wbemcli in test_wbemcli.py Details: - In test_wbemcli.py, the `wbemcli` command was invoked with `PYTHONPATH=.` which causes the `wbemcli` script from the working directory to be used and not the one generated by the Pip installer that wrappers that script. In certain situations this causes the testcases to fail because the wbemcli script in the working directory is not found by the wrapper wbemcli script. This was fixed by removing PYTHONPATH=. from the invocation. I cannot currrently reproduce the error situation, but the change seems correct in any case (because the wrapper script is supposed to be used). - Simplified invocation of the `wbemcli` command in `test_wbemcli.py` by no longer setting pipefail (the invocation does not use piping). - Improved the assertion failure messages, for better diagnostics in case of failures. Signed-off-by: Andreas Maier --- testsuite/test_wbemcli.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/testsuite/test_wbemcli.py b/testsuite/test_wbemcli.py index 1716bdd72..e6bf9cc07 100755 --- a/testsuite/test_wbemcli.py +++ b/testsuite/test_wbemcli.py @@ -143,8 +143,7 @@ def test(self): # pylint: disable=missing-docstring # Disable python warnings for wbemcli call # because some imports generate deprecated warnings # that appear in std_err when nothing expected - bash_cmd = 'bash -c "set -o pipefail; PYTHONPATH=. ' \ - 'PYTHONWARNINGS= %s"' % cmd + bash_cmd = 'bash -c "PYTHONWARNINGS= %s"' % cmd proc = Popen(bash_cmd, shell=True, stdout=PIPE, stderr=PIPE) std_out, std_err = proc.communicate() @@ -159,29 +158,30 @@ def test(self): # pylint: disable=missing-docstring if test_params.expected_exitcode is not None: self.assertEqual(exitcode, test_params.expected_exitcode, - ('Test %s: Unexpected ExitCode Err. ' - 'Expected %s: cmd="%s": ' - 'exitcode %s: stderr=%s' % + ("Test %s: Unexpected exit code " + "(expected %s, got %s) from command:\n" + "%s\n" + "stderr:\n" + "%s" % (test_name, test_params.expected_exitcode, - cmd, - exitcode, std_err))) + exitcode, cmd, std_err))) if test_params.expected_stderr is None: if re.search('ImportWarning', std_err) is None: self.assertEqual(std_err, "", - 'Test %s stderr not empty as ' + 'Test %s: stderr not empty as ' 'expected. Returned %s' % (test_name, std_err)) else: print('Ignored junk in stderr %s' % std_err) self.assertEqual(std_err, "", - 'Test %s stderr not empty as expected. ' + 'Test %s: stderr not empty as expected. ' 'Returned %s' % (test_name, std_err)) else: for item in test_params.expected_stderr: match_result = re.search(item, std_err) - self.assertNotEqual(match_result, None, 'Test %s, ' + self.assertNotEqual(match_result, None, 'Test %s: ' 'stderr did not match test ' 'definition. Expected %s in %s' % (test_name, item, std_err)) @@ -190,12 +190,12 @@ def test(self): # pylint: disable=missing-docstring for item in test_params.expected_stdout: match_result = re.search(item, std_out) self.assertNotEqual(match_result, None, - 'Test=%s, stdout did not match ' + 'Test=%s: stdout did not match ' 'test definition. Expected %s in %s' % (test_name, item, std_out)) else: self.assertEqual(std_out, "", - 'Test %s stdout not empty as expected. ' + 'Test %s: stdout not empty as expected. ' 'Returned %s' % (test_name, std_out)) return test