I've some Python pytests that call (indirectly)
key = joserfc.jwk.RSAKey.import_key(string).
This is pretty slow so I'm hoping there is a way I can save the (string,key) combination in a cache, and then use that to stub the call.
I've tried saving key using pickle, but I get
TypeError: cannot pickle 'cryptography.hazmat.bindings._rust.openssl.rsa.RSAPrivateKey' object
cryptographypackage. See cryptography.io/en/stable/hazmat/primitives/asymmetric/rsa/… and cryptography.io/en/stable/hazmat/primitives/asymmetric/rsa/….key(as returned from theimport_keymethod) is neither an RSAPublicKey nor an RSAPrivateKey. So it seems I still need to callimport_key(so the following statements that usekeyare unaffected by the stubbing).