D-Bus Testing: fail the test on unexpected success of syncevolution

If we pass False to runCmdline's expectSuccess then the test should
fail, because we expected failure. Previously only checking if
application succeeded when expected was done.
This commit is contained in:
Krzesimir Nowak 2012-04-19 16:07:47 +02:00 committed by Patrick Ohly
parent 086a02317b
commit 567a337017
1 changed files with 8 additions and 1 deletions

View File

@ -3748,8 +3748,15 @@ class TestCmdline(unittest.TestCase, DBusUtil):
s = subprocess.Popen(a, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=cmdline_env)
out, err = s.communicate()
doFail = False
if expectSuccess and s.returncode != 0:
result = 'syncevolution command failed.\nOutput:\n%s' % out
result = 'syncevolution command failed.'
doFail = True
elif not expectSuccess and s.returncode == 0:
result = 'syncevolution was expected to fail, but it succeeded.'
doFail = True
if doFail:
result += '\nOutput:\n%s' % out
if not preserveOutputOrder:
result += '\nSeparate stderr:\n%s' % err
self.fail(result)