'Verify that if we try to switch protocols and it fails, the connection
stays up and we can go back to speaking AMP.'

def test_protocolSwitchFail(self, switcher=SimpleSymmetricCommandProtocol):

    self.testSucceeded = False
    serverDeferred = defer.Deferred()
    serverProto = switcher(serverDeferred)
    clientDeferred = defer.Deferred()
    clientProto = switcher(clientDeferred)
    (c, s, p) = connectedServerAndClient(ServerClass=(lambda : serverProto), ClientClass=(lambda : clientProto))
    L = []
    c.switchToTestProtocol(fail=True).addErrback(L.append)
    p.flush()
    L.pop().trap(UnknownProtocol)
    self.assertFalse(self.testSucceeded)
    c.sendHello('world').addCallback(L.append)
    p.flush()
    self.assertEqual(L.pop()['hello'], 'world')
