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

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