diagnose: Move negating diagnose result inside try bock

A caught Exception should always be considered a failed test.

Signed-off-by: Matthias Dellweg <2500@gmx.de>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Matthias Dellweg 2019-09-22 10:40:24 +00:00 committed by Sunil Mohan Adapa
parent aca0c65d68
commit cb3e050722
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -423,12 +423,14 @@ def diagnose_netcat(host, port, input='', negate=False):
result = 'failed'
else:
result = 'passed'
if negate:
result = 'failed' if result == 'passed' else 'passed'
except Exception:
result = 'failed'
test = _('Connect to {host}:{port}')
if negate:
result = 'failed' if result == 'passed' else 'passed'
test = _('Cannot connect to {host}:{port}')
return [test.format(host=host, port=port), result]