':py:obj:`dump_privatekey` writes an encrypted PEM when given a callback which
returns the correct passphrase.'

def test_dump_privatekey_passphraseCallback(self):

    passphrase = b('foo')
    called = []
    def cb(writing):
        called.append(writing)
        return passphrase
    key = load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM)
    pem = dump_privatekey(FILETYPE_PEM, key, GOOD_CIPHER, cb)
    self.assertTrue(isinstance(pem, binary_type))
    self.assertEqual(called, [True])
    loadedKey = load_privatekey(FILETYPE_PEM, pem, passphrase)
    self.assertTrue(isinstance(loadedKey, PKeyType))
    self.assertEqual(loadedKey.type(), key.type())
    self.assertEqual(loadedKey.bits(), key.bits())
