PYTHON-2438 Fix str representation of BulkWriteError (#522)
This commit is contained in:
parent
92aed33694
commit
86d58113e5
@ -240,8 +240,9 @@ class BulkWriteError(OperationFailure):
|
||||
def __init__(self, results):
|
||||
super(BulkWriteError, self).__init__(
|
||||
"batch op errors occurred", 65, results)
|
||||
# For pickle support
|
||||
self.args = (results,)
|
||||
|
||||
def __reduce__(self):
|
||||
return self.__class__, (self.details,)
|
||||
|
||||
|
||||
class InvalidOperation(PyMongoError):
|
||||
|
||||
@ -93,6 +93,7 @@ class TestErrors(PyMongoTestCase):
|
||||
def test_pickle_BulkWriteError(self):
|
||||
exc = BulkWriteError({})
|
||||
self.assertOperationFailureEqual(exc, pickle.loads(pickle.dumps(exc)))
|
||||
self.assertIn("batch op errors occurred", str(exc))
|
||||
|
||||
def test_pickle_EncryptionError(self):
|
||||
cause = OperationFailure('error', code=5, details={},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user