def test_pickle_EncryptionError(self):
     cause = OperationFailure('error', code=5, details={},
                              max_wire_version=7)
     exc = EncryptionError(cause)
     exc2 = pickle.loads(pickle.dumps(exc))
     self.assertPyMongoErrorEqual(exc, exc2)
     self.assertOperationFailureEqual(cause, exc2.cause)
Пример #2
0
def _wrap_encryption_errors():
    """Context manager to wrap encryption related errors."""
    try:
        yield
    except BSONError:
        # BSON encoding/decoding errors are unrelated to encryption so
        # we should propagate them unchanged.
        raise
    except Exception as exc:
        raise EncryptionError(exc)