'L{KnownHostsFile.hasHostKey} raises L{HostKeyChanged} if the host key is
present in the underlying file, but different from the expected one.
The resulting exception should have an C{offendingEntry} indicating the
given entry.'

def test_savedEntryHasKeyMismatch(self):

    hostsFile = self.loadSampleHostsFile()
    entries = list(hostsFile.iterentries())
    exception = self.assertRaises(HostKeyChanged, hostsFile.hasHostKey, 'www.twistedmatrix.com', Key.fromString(otherSampleKey))
    self.assertEqual(exception.offendingEntry, entries[0])
    self.assertEqual(exception.lineno, 1)
    self.assertEqual(exception.path, hostsFile.savePath)
