diff --git a/test/asynchronous/test_pooling.py b/test/asynchronous/test_pooling.py index 2f0d5fc96..9db9b5ab3 100644 --- a/test/asynchronous/test_pooling.py +++ b/test/asynchronous/test_pooling.py @@ -29,7 +29,6 @@ from pymongo import AsyncMongoClient, message, timeout from pymongo.errors import AutoReconnect, ConnectionFailure, DuplicateKeyError from pymongo.hello import HelloCompat from pymongo.lock import _async_create_lock -from pymongo.read_preferences import ReadPreference sys.path[0:0] = [""] diff --git a/test/asynchronous/test_retryable_writes.py b/test/asynchronous/test_retryable_writes.py index 97f99dc16..a85b181fe 100644 --- a/test/asynchronous/test_retryable_writes.py +++ b/test/asynchronous/test_retryable_writes.py @@ -48,6 +48,7 @@ from pymongo.errors import ( AutoReconnect, ConnectionFailure, NotPrimaryError, + PyMongoError, ServerSelectionTimeoutError, WriteConcernError, ) @@ -775,9 +776,7 @@ class TestErrorPropagationAfterEncounteringMultipleErrors(AsyncIntegrationTest): # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. - from pymongo.errors import OperationFailure - - with self.assertRaises(Exception) as exc: + with self.assertRaises(PyMongoError) as exc: await client.test.test.insert_one({}) # Assert that the error code of the server error is 91. diff --git a/test/asynchronous/test_transactions.py b/test/asynchronous/test_transactions.py index 2376a1af2..e17bfb14c 100644 --- a/test/asynchronous/test_transactions.py +++ b/test/asynchronous/test_transactions.py @@ -705,7 +705,7 @@ class TestTransactionsConvenientAPI(AsyncTransactionsBase): async with self.client.start_session() as s: await s.with_transaction(callback) end = time.monotonic() - self.assertLess(abs(end - start - (no_backoff_time + 2.2)), 1) # sum of 5 backoffs is 2.2 + self.assertLess(abs(end - start - (no_backoff_time + 2.2)), 1) # sum of 13 backoffs is 2.2 class TestOptionsInsideTransactionProse(AsyncTransactionsBase): diff --git a/test/test_pooling.py b/test/test_pooling.py index 0f7ef144f..95558d00d 100644 --- a/test/test_pooling.py +++ b/test/test_pooling.py @@ -29,7 +29,6 @@ from pymongo import MongoClient, message, timeout from pymongo.errors import AutoReconnect, ConnectionFailure, DuplicateKeyError from pymongo.hello import HelloCompat from pymongo.lock import _create_lock -from pymongo.read_preferences import ReadPreference sys.path[0:0] = [""] diff --git a/test/test_retryable_writes.py b/test/test_retryable_writes.py index 4daa5643c..a8b1280f3 100644 --- a/test/test_retryable_writes.py +++ b/test/test_retryable_writes.py @@ -48,6 +48,7 @@ from pymongo.errors import ( AutoReconnect, ConnectionFailure, NotPrimaryError, + PyMongoError, ServerSelectionTimeoutError, WriteConcernError, ) @@ -771,9 +772,7 @@ class TestErrorPropagationAfterEncounteringMultipleErrors(IntegrationTest): # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. - from pymongo.errors import OperationFailure - - with self.assertRaises(Exception) as exc: + with self.assertRaises(PyMongoError) as exc: client.test.test.insert_one({}) # Assert that the error code of the server error is 91. diff --git a/test/test_transactions.py b/test/test_transactions.py index 0159d9231..609105ec2 100644 --- a/test/test_transactions.py +++ b/test/test_transactions.py @@ -693,7 +693,7 @@ class TestTransactionsConvenientAPI(TransactionsBase): with self.client.start_session() as s: s.with_transaction(callback) end = time.monotonic() - self.assertLess(abs(end - start - (no_backoff_time + 2.2)), 1) # sum of 5 backoffs is 2.2 + self.assertLess(abs(end - start - (no_backoff_time + 2.2)), 1) # sum of 13 backoffs is 2.2 class TestOptionsInsideTransactionProse(TransactionsBase):