'Alice connects to Bob.  Alice writes some bytes and then shuts down the
connection.  Bob receives the bytes from the connection and then pauses
the transport object.  Shortly afterwards Bob resumes the transport
object.  At that point, Bob is notified that the connection has been
closed.
This is no problem for most reactors.  The underlying event notification
API will probably just remind them that the connection has been closed.
It is a little tricky for win32eventreactor (MsgWaitForMultipleObjects).
MsgWaitForMultipleObjects will only deliver the close notification once.
The reactor needs to remember that notification until Bob resumes the
transport.'

def test_connectionLostAfterPausedTransport(self):

    class Pauser(ConnectableProtocol, ):
        def __init__(self):
            self.events = []
        def dataReceived(self, bytes):
            self.events.append('paused')
            self.transport.pauseProducing()
            self.reactor.callLater(0, self.resume)
        def resume(self):
            self.events.append('resumed')
            self.transport.resumeProducing()
        def connectionLost(self, reason):
            self.events.append('lost')
            ConnectableProtocol.connectionLost(self, reason)
    class Client(ConnectableProtocol, ):
        def connectionMade(self):
            self.transport.write('some    bytes    for    you')
            self.transport.loseConnection()
    pauser = Pauser()
    runProtocolsWithReactor(self, pauser, Client(), TCPCreator())
    self.assertEqual(pauser.events, ['paused', 'resumed', 'lost'])
