'A TCP transport which is written to after the connection has been shut
down should notify its protocol that the connection has been lost, even
if the TCP transport is not actively being monitored for read events
(ie, pauseProducing was called on it).'

def test_writeAfterShutdownWithoutReading(self):

    if (reactor.__class__.__name__ == 'IOCPReactor'):
        raise unittest.SkipTest('iocpreactor    does    not,    in    fact,    stop    reading    immediately    after    pauseProducing    is    called.    This    results    in    a    bonus    disconnection    notification.    Under    some    circumstances,    it    might    be    possible    to    not    receive    this    notifications    (specifically,    pauseProducing,    deliver    some    data,    proceed    with    this    test).')
    clientPaused = defer.Deferred()
    serverLost = defer.Deferred()
    class Disconnecter(protocol.Protocol, ):
        '\n                                                Protocol    for    the    server    side    of    the    connection    which    disconnects\n                                                itself    in    a    callback    on    clientPaused    and    publishes    notification\n                                                when    its    connection    is    actually    lost.\n                                                '
        def connectionMade(self):
            '\n                                                                Set    up    a    callback    on    clientPaused    to    lose    the    connection.\n                                                                '
            msg('Disconnector.connectionMade')
            def disconnect(ignored):
                msg('Disconnector.connectionMade    disconnect')
                self.transport.loseConnection()
                msg('loseConnection    called')
            clientPaused.addCallback(disconnect)
        def connectionLost(self, reason):
            '\n                                                                Notify    observers    that    the    server    side    of    the    connection    has\n                                                                ended.\n                                                                '
            msg('Disconnecter.connectionLost')
            serverLost.callback(None)
            msg('serverLost    called    back')
    server = protocol.ServerFactory()
    server.protocol = Disconnecter
    port = reactor.listenTCP(0, server, interface='127.0.0.1')
    self.addCleanup(port.stopListening)
    addr = port.getHost()
    @implementer(IPullProducer)
    class Infinite(object, ):
        '\n                                                A    producer    which    will    write    to    its    consumer    as    long    as\n                                                resumeProducing    is    called.\n\n                                                @ivar    consumer:    The    L{IConsumer}    which    will    be    written    to.\n                                                '
        def __init__(self, consumer):
            self.consumer = consumer
        def resumeProducing(self):
            msg('Infinite.resumeProducing')
            self.consumer.write('x')
            msg('Infinite.resumeProducing    wrote    to    consumer')
        def stopProducing(self):
            msg('Infinite.stopProducing')
    class UnreadingWriter(protocol.Protocol, ):
        '\n                                                Trivial    protocol    which    pauses    its    transport    immediately    and    then\n                                                writes    some    bytes    to    it.\n                                                '
        def connectionMade(self):
            msg('UnreadingWriter.connectionMade')
            self.transport.pauseProducing()
            clientPaused.callback(None)
            msg('clientPaused    called    back')
            def write(ignored):
                msg('UnreadingWriter.connectionMade    write')
                producer = Infinite(self.transport)
                msg('UnreadingWriter.connectionMade    write    created    producer')
                self.transport.registerProducer(producer, False)
                msg('UnreadingWriter.connectionMade    write    registered    producer')
            serverLost.addCallback(write)
    client = MyClientFactory()
    client.protocolFactory = UnreadingWriter
    clientConnectionLost = client.deferred
    def cbClientLost(ignored):
        msg('cbClientLost')
        return client.lostReason
    clientConnectionLost.addCallback(cbClientLost)
    msg(('Connecting    to    %s:%s' % (addr.host, addr.port)))
    reactor.connectTCP(addr.host, addr.port, client)
    msg('Returning    Deferred')
    return self.assertFailure(clientConnectionLost, error.ConnectionLost)
