Skip to content

Commit

Permalink
Correct bash execution call
Browse files Browse the repository at this point in the history
  • Loading branch information
KSchopmeyer committed Jul 16, 2017
1 parent 6d74173 commit 99d2d89
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions testsuite/test_wbemcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,20 @@ def test(self): # pylint: disable=missing-docstring
'wbemcli_quit_script.py')
term_script_param = '-s %s' % term_script_file

command = ('wbemcli http://blah %s %s' %
(test_params.cmd, term_script_param))
cmd = ('wbemcli http://blah %s %s' % (test_params.cmd,
term_script_param))
# Disable python warnings for wbemcli call
# because some imports generate deprecated warnings
# that appear in std_err when nothing expected
if os.name == 'nt':
pywarn = 'set PYTHONWARNINGS= &'
else:
pywarn = 'export PYTHONWARNINGS= "" &&'
# if os.name == 'nt':
# pywarn = 'set PYTHONWARNINGS= &'
# else:
# pywarn = 'export PYTHONWARNINGS= "" &&'

# command = 'PYTHONWARNINGS="" && %s' % command
bash_cmd = 'bash -c "set -o pipefail; PYTHONWARNINGS= %s"' % cmd

command = '%s %s' % (pywarn, command)
proc = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
proc = Popen(bash_cmd, shell=True, stdout=PIPE, stderr=PIPE)
std_out, std_err = proc.communicate()
exitcode = proc.returncode
print('exitcode %s std_out:\n%s\nstd_err:\n%s' % (exitcode,
Expand All @@ -140,7 +142,7 @@ def test(self): # pylint: disable=missing-docstring
'Expected %s: cmd="%s": '
'exitcode %s: stderr=%s' %
(test_name, test_params.expected_exitcode,
command,
cmd,
exitcode, std_err)))

if test_params.expected_stderr is None:
Expand Down

0 comments on commit 99d2d89

Please sign in to comment.