'Even after a new entry has been added in memory but not yet saved, the
L{HostKeyChanged} exception raised by L{KnownHostsFile.hasHostKey} has a
C{lineno} attribute which indicates the 1-based line number of the
offending entry in the underlying file when the given host key does not
match the expected host key.'

def test_savedEntryAfterAddHasKeyMismatch(self):

    hostsFile = self.loadSampleHostsFile()
    hostsFile.addHostKey('www.example.com', Key.fromString(otherSampleKey))
    exception = self.assertRaises(HostKeyChanged, hostsFile.hasHostKey, 'www.twistedmatrix.com', Key.fromString(otherSampleKey))
    self.assertEqual(exception.lineno, 1)
    self.assertEqual(exception.path, hostsFile.savePath)
