def test_sendDisconnect(self):
        """
        Test that disconnection messages are sent correctly.  Payload::
            uint32 reason code
            string reason description
            string language
        """
        disconnected = [False]
        def stubLoseConnection():
            disconnected[0] = True
        self.transport.loseConnection = stubLoseConnection
        self.proto.sendDisconnect(0xff, b"test")
        self.assertEqual(
            self.packets,
            [(transport.MSG_DISCONNECT,
              b"\x00\x00\x00\xff\x00\x00\x00\x04test\x00\x00\x00\x00")])
        self.assertTrue(disconnected[0])

        Test that disconnection messages are sent correctly.  Payload::
            uint32 reason code
            string reason description
            string language
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_transport.py