'Test that loseConnection sends a disconnect message and closes the
connection.'

def test_loseConnection(self):

    disconnected = [False]
    def stubLoseConnection():
        disconnected[0] = True
    self.transport.loseConnection = stubLoseConnection
    self.proto.loseConnection()
    self.assertEqual(self.packets[0][0], transport.MSG_DISCONNECT)
    self.assertEqual(self.packets[0][1][3:4], chr(transport.DISCONNECT_CONNECTION_LOST))
