'If TLSMemoryBIOProtocol.loseConnection is called multiple times, all
but the first call have no effect.'

def test_loseConnectionTwice(self):

    (tlsClient, tlsServer, handshakeDeferred, disconnectDeferred) = self.handshakeProtocols()
    self.successResultOf(handshakeDeferred)
    calls = []
    def _shutdownTLS(shutdown=tlsClient._shutdownTLS):
        calls.append(1)
        return shutdown()
    tlsClient._shutdownTLS = _shutdownTLS
    tlsClient.write('x')
    tlsClient.loseConnection()
    self.assertTrue(tlsClient.disconnecting)
    self.assertEqual(calls, [1])
    tlsClient.loseConnection()
    self.assertEqual(calls, [1])
    return disconnectDeferred
