Don't try to attach known_hosts if it's not there

Fixes long tracebacks if something strange and wrong happens in the
gate.

Change-Id: I094a153e300a1a5652166e9976b4296b8d377f04
This commit is contained in:
Yuriy Taraday
2014-02-12 14:07:58 +04:00
parent 336a0d3f4e
commit 023c33a0c4

View File

@@ -196,7 +196,12 @@ class BaseGitReviewTestCase(testtools.TestCase, GerritHelpers):
# Attach known_hosts to test results if anything fails
@self.addOnException
def add_known_hosts(exc_info):
content.attach_file(self, self._dir('ssh', 'known_hosts'))
known_hosts = self._dir('ssh', 'known_hosts')
if os.path.exists(known_hosts):
content.attach_file(self, known_hosts)
else:
self.addDetail('known_hosts',
content.text_content('Not found'))
for cmd in ('ssh', 'scp'):
cmd_file = self._dir('ssh', cmd)