Ticket #6556: notQuiteMaximumLineLengthUnfinished.patch

File notQuiteMaximumLineLengthUnfinished.patch, 1.2 KB (added by zooko, 8 years ago)
  • twisted/protocols/test/test_basic.py

     
    326326        self.assertTrue(transport.disconnecting)
    327327
    328328
     329    def test_notQuiteMaximumLineLengthUnfinished(self):
     330        """
     331        C{LineReceiver} doesn't disconnect the transport it if
     332        receives a non-finished line whose length, counting the
     333        delimiter, is longer than its C{MAX_LENGTH} but shorter than
     334        its C{MAX_LENGTH} + len(delimiter). (When the first part that
     335        exceeds the max is the beginning of the delimiter.)
     336        """
     337        proto = basic.LineReceiver()
     338        # '\r\n' is the default, but we set it just to be explicit in this test.
     339        proto.delimiter = '\r\n'
     340        transport = proto_helpers.StringTransport()
     341        proto.makeConnection(transport)
     342        proto.dataReceived((b'x' * proto.MAX_LENGTH) + proto.delimiter[:len(proto.delimiter)-1])
     343        self.assertFalse(transport.disconnecting)
     344
     345
    329346    def test_rawDataError(self):
    330347        """
    331348        C{LineReceiver.dataReceived} forwards errors returned by