def test_NEWKEYS(self):
        """
        Test that NEWKEYS transitions the keys from nextEncryptions to
        currentEncryptions.
        """
        self.test_KEXINITMultipleAlgorithms()
        secure = [False]
        def stubConnectionSecure():
            secure[0] = True
        self.proto.connectionSecure = stubConnectionSecure

        self.proto.nextEncryptions = transport.SSHCiphers(
            b'none', b'none', b'none', b'none')
        self.simulateKeyExchange(b'AB', b'CD')
        self.assertIsNot(self.proto.currentEncryptions,
                         self.proto.nextEncryptions)

        self.proto.nextEncryptions = MockCipher()
        self.proto.ssh_NEWKEYS(b'')
        self.assertIsNone(self.proto.outgoingCompression)
        self.assertIsNone(self.proto.incomingCompression)
        self.assertIs(self.proto.currentEncryptions,
                      self.proto.nextEncryptions)
        self.assertTrue(secure[0])
        self.proto.outgoingCompressionType = b'zlib'
        self.simulateKeyExchange(b'AB', b'GH')
        self.proto.ssh_NEWKEYS(b'')
        self.assertIsNotNone(self.proto.outgoingCompression)
        self.proto.incomingCompressionType = b'zlib'
        self.simulateKeyExchange(b'AB', b'IJ')
        self.proto.ssh_NEWKEYS(b'')
        self.assertIsNotNone(self.proto.incomingCompression)

        Test that NEWKEYS transitions the keys from nextEncryptions to
        currentEncryptions.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_transport.py