'Existing entries in the I{known_hosts} file are reflected by the
L{KnownHostsFile} created by L{_NewConnectionHelper} when none is
supplied to it.'

def test_readExisting(self):

    key = CommandFactory().publicKeys['ssh-rsa']
    path = FilePath(self.mktemp())
    knownHosts = KnownHostsFile(path)
    knownHosts.addHostKey('127.0.0.1', key)
    knownHosts.save()
    msg(('Created    known_hosts    file    at    %r' % (path.path,)))
    home = os.path.expanduser('~/')
    default = path.path.replace(home, '~/')
    self.patch(_NewConnectionHelper, '_KNOWN_HOSTS', default)
    msg(('Patched    _KNOWN_HOSTS    with    %r' % (default,)))
    loaded = _NewConnectionHelper._knownHosts()
    self.assertTrue(loaded.hasHostKey('127.0.0.1', key))
