def test_write(self):
        """
        Test that write handles data correctly.  Send data up to the size
        of the remote window, splitting the data into packets of length
        remoteMaxPacket.
        """
        cb = [False]
        def stubStopWriting():
            cb[0] = True
        # no window to start with
        self.channel.stopWriting = stubStopWriting
        self.channel.write(b'd')
        self.channel.write(b'a')
        self.assertFalse(self.channel.areWriting)
        self.assertTrue(cb[0])
        # regular write
        self.channel.addWindowBytes(20)
        self.channel.write(b'ta')
        data = self.conn.data[self.channel]
        self.assertEqual(data, [b'da', b'ta'])
        self.assertEqual(self.channel.remoteWindowLeft, 16)
        # larger than max packet
        self.channel.write(b'12345678901')
        self.assertEqual(data, [b'da', b'ta', b'1234567890', b'1'])
        self.assertEqual(self.channel.remoteWindowLeft, 5)
        # running out of window
        cb[0] = False
        self.channel.write(b'123456')
        self.assertFalse(self.channel.areWriting)
        self.assertTrue(cb[0])
        self.assertEqual(data, [b'da', b'ta', b'1234567890', b'1', b'12345'])
        self.assertEqual(self.channel.buf, b'6')
        self.assertEqual(self.channel.remoteWindowLeft, 0)

        Test that write handles data correctly.  Send data up to the size
        of the remote window, splitting the data into packets of length
        remoteMaxPacket.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_channel.py