def test_sendPacketBoth(self):
        """
        Test that packets sent while compression and encryption are
        enabled are sent correctly.  The packet type and data should be
        compressed and then the whole packet should be encrypted.
        """
        proto = MockTransportBase()
        proto.makeConnection(self.transport)
        self.finishKeyExchange(proto)
        proto.currentEncryptions = testCipher = MockCipher()
        proto.outgoingCompression = MockCompression()
        message = ord('A')
        payload = b'BC'
        self.transport.clear()
        proto.sendPacket(message, payload)
        self.assertTrue(testCipher.usedEncrypt)
        value = self.transport.value()
        self.assertEqual(
            value,
            # Four byte length prefix
            b'\x00\x00\x00\x0e'
            # One byte padding length
            b'\x09'
            # Compressed application data
            b'CBA\x66'
            # "Random" padding - see the secureRandom monkeypatch in setUp
            b'\x99\x99\x99\x99\x99\x99\x99\x99\x99'
            # The MAC
            b'\x02')

        Test that packets sent while compression and encryption are
        enabled are sent correctly.  The packet type and data should be
        compressed and then the whole packet should be encrypted.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_transport.py