Merge branch 'master' of github.com:mongodb/mongo-python-driver

This commit is contained in:
Steven Silvester 2024-09-14 15:32:32 -05:00
commit b698daf194
No known key found for this signature in database
GPG Key ID: B1BF5EC3A8B32F91
4 changed files with 8 additions and 8 deletions

View File

@ -1185,7 +1185,7 @@ class AsyncMongoClient(common.BaseObject, Generic[_DocumentType]):
def __del__(self) -> None:
"""Check that this AsyncMongoClient has been closed and issue a warning if not."""
try:
if not self._closed:
if self._opened and not self._closed:
warnings.warn(
(
f"Unclosed {type(self).__name__} opened at:\n{self._topology_settings._stack}"

View File

@ -1185,7 +1185,7 @@ class MongoClient(common.BaseObject, Generic[_DocumentType]):
def __del__(self) -> None:
"""Check that this MongoClient has been closed and issue a warning if not."""
try:
if not self._closed:
if self._opened and not self._closed:
warnings.warn(
(
f"Unclosed {type(self).__name__} opened at:\n{self._topology_settings._stack}"

View File

@ -169,7 +169,7 @@ class TestGSSAPI(unittest.IsolatedAsyncioTestCase):
client = AsyncMongoClient(mech_uri)
await client[GSSAPI_DB].collection.find_one()
set_name = await client.admin.command(HelloCompat.LEGACY_CMD).get("setName")
set_name = async_client_context.replica_set_name
if set_name:
if not self.service_realm_required:
# Without authMechanismProperties
@ -242,7 +242,7 @@ class TestGSSAPI(unittest.IsolatedAsyncioTestCase):
thread.join()
self.assertTrue(thread.success)
set_name = await client.admin.command(HelloCompat.LEGACY_CMD).get("setName")
set_name = async_client_context.replica_set_name
if set_name:
client = AsyncMongoClient(
GSSAPI_HOST,
@ -296,7 +296,7 @@ class TestSASLPlain(unittest.IsolatedAsyncioTestCase):
client = AsyncMongoClient(uri)
await client.ldap.test.find_one()
set_name = await client.admin.command(HelloCompat.LEGACY_CMD).get("setName")
set_name = async_client_context.replica_set_name
if set_name:
client = AsyncMongoClient(
SASL_HOST,

View File

@ -169,7 +169,7 @@ class TestGSSAPI(unittest.TestCase):
client = MongoClient(mech_uri)
client[GSSAPI_DB].collection.find_one()
set_name = client.admin.command(HelloCompat.LEGACY_CMD).get("setName")
set_name = client_context.replica_set_name
if set_name:
if not self.service_realm_required:
# Without authMechanismProperties
@ -242,7 +242,7 @@ class TestGSSAPI(unittest.TestCase):
thread.join()
self.assertTrue(thread.success)
set_name = client.admin.command(HelloCompat.LEGACY_CMD).get("setName")
set_name = client_context.replica_set_name
if set_name:
client = MongoClient(
GSSAPI_HOST,
@ -296,7 +296,7 @@ class TestSASLPlain(unittest.TestCase):
client = MongoClient(uri)
client.ldap.test.find_one()
set_name = client.admin.command(HelloCompat.LEGACY_CMD).get("setName")
set_name = client_context.replica_set_name
if set_name:
client = MongoClient(
SASL_HOST,