def test_set_passwd_cb(self, tmpfile):
    '\n        `Context.set_passwd_cb` accepts a callable which will be invoked when\n        a private key is loaded from an encrypted PEM.\n        '
    passphrase = b'foobar'
    pemFile = self._write_encrypted_pem(passphrase, tmpfile)
    calledWith = []

    def passphraseCallback(maxlen, verify, extra):
        calledWith.append((maxlen, verify, extra))
        return passphrase
    context = Context(TLSv1_METHOD)
    context.set_passwd_cb(passphraseCallback)
    context.use_privatekey_file(pemFile)
    assert (len(calledWith) == 1)
    assert isinstance(calledWith[0][0], int)
    assert isinstance(calledWith[0][1], int)
    assert (calledWith[0][2] is None)
`Context.set_passwd_cb` accepts a callable which will be invoked when
a private key is loaded from an encrypted PEM.
def test_set_passwd_cb(self, tmpfile):
    '\n        `Context.set_passwd_cb` accepts a callable which will be invoked when\n        a private key is loaded from an encrypted PEM.\n        '
    passphrase = b'foobar'
    pemFile = self._write_encrypted_pem(passphrase, tmpfile)
    calledWith = []

    def passphraseCallback(maxlen, verify, extra):
        calledWith.append((maxlen, verify, extra))
        return passphrase
    context = Context(TLSv1_METHOD)
    context.set_passwd_cb(passphraseCallback)
    context.use_privatekey_file(pemFile)
    assert (len(calledWith) == 1)
    assert isinstance(calledWith[0][0], int)
    assert isinstance(calledWith[0][1], int)
    assert (calledWith[0][2] is None)