Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymongo/_csot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _TimeoutContext(AbstractContextManager[Any]):
Use :func:`pymongo.timeout` instead::
with pymongo.timeout(0.5):
client.test.test.insert_one({})
client.db.coll.insert_one({})
"""

def __init__(self, timeout: Optional[float]):
Expand Down
24 changes: 12 additions & 12 deletions test/asynchronous/test_async_cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
class TestAsyncCancellation(AsyncIntegrationTest):
async def test_async_cancellation_closes_connection(self):
pool = await async_get_pool(self.client)
await self.client.db.test.insert_one({"x": 1})
self.addAsyncCleanup(self.client.db.test.delete_many, {})
await self.client.db.coll.insert_one({"x": 1})
self.addAsyncCleanup(self.client.db.coll.delete_many, {})

conn = one(pool.conns)

async def task():
await self.client.db.test.find_one({"$where": delay(0.2)})
await self.client.db.coll.find_one({"$where": delay(0.2)})

task = asyncio.create_task(task())

Expand All @@ -50,13 +50,13 @@ async def task():

@async_client_context.require_transactions
async def test_async_cancellation_aborts_transaction(self):
await self.client.db.test.insert_one({"x": 1})
self.addAsyncCleanup(self.client.db.test.delete_many, {})
await self.client.db.coll.insert_one({"x": 1})
self.addAsyncCleanup(self.client.db.coll.delete_many, {})

session = self.client.start_session()

async def callback(session):
await self.client.db.test.find_one({"$where": delay(0.2)}, session=session)
await self.client.db.coll.find_one({"$where": delay(0.2)}, session=session)

async def task():
await session.with_transaction(callback)
Expand All @@ -73,10 +73,10 @@ async def task():

@async_client_context.require_failCommand_blockConnection
async def test_async_cancellation_closes_cursor(self):
await self.client.db.test.insert_many([{"x": 1}, {"x": 2}])
self.addAsyncCleanup(self.client.db.test.delete_many, {})
await self.client.db.coll.insert_many([{"x": 1}, {"x": 2}])
self.addAsyncCleanup(self.client.db.coll.delete_many, {})

cursor = self.client.db.test.find({}, batch_size=1)
cursor = self.client.db.coll.find({}, batch_size=1)
await cursor.next()

# Make sure getMore commands block
Expand All @@ -103,8 +103,8 @@ async def task():
@async_client_context.require_change_streams
@async_client_context.require_failCommand_blockConnection
async def test_async_cancellation_closes_change_stream(self):
self.addAsyncCleanup(self.client.db.test.delete_many, {})
change_stream = await self.client.db.test.watch(batch_size=2)
self.addAsyncCleanup(self.client.db.coll.delete_many, {})
change_stream = await self.client.db.coll.watch(batch_size=2)
event = asyncio.Event()

# Make sure getMore commands block
Expand All @@ -116,7 +116,7 @@ async def test_async_cancellation_closes_change_stream(self):

async def task():
async with self.fail_point(fail_command):
await self.client.db.test.insert_many([{"x": 1}, {"x": 2}])
await self.client.db.coll.insert_many([{"x": 1}, {"x": 2}])
event.set()
await change_stream.next()

Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_async_contextvars_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def test_context_vars_are_reset_in_executor(self):
if sys.version_info < (3, 12):
self.skipTest("Test requires asyncio.Task.get_context (added in Python 3.12)")

await self.client.db.test.insert_one({"x": 1})
await self.client.db.coll.insert_one({"x": 1})
# Value each contextvar is reset to at the start of the executor task.
expected = {"TIMEOUT": None, "RTT": 0.0, "DEADLINE": float("inf"), "OP_ID": None}
for server in self.client._topology._servers.values():
Expand Down
14 changes: 7 additions & 7 deletions test/asynchronous/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def test_gssapi_threaded(self):
# collection.find_one with a 1-second delay, forcing it to check out
# multiple connections from the pool concurrently, proving that
# auto-authentication works with GSSAPI.
collection = db.test
collection = db.coll
if not await collection.count_documents({}):
try:
await collection.drop()
Expand Down Expand Up @@ -340,7 +340,7 @@ async def test_sasl_plain(self):
authSource=SASL_DB,
authMechanism="PLAIN",
)
await client.ldap.test.find_one()
await client.ldap.coll.find_one()

assert SASL_USER is not None
assert SASL_PASS is not None
Expand All @@ -352,7 +352,7 @@ async def test_sasl_plain(self):
SASL_DB,
)
client = self.simple_client(uri)
await client.ldap.test.find_one()
await client.ldap.coll.find_one()

set_name = async_client_context.replica_set_name
if set_name:
Expand All @@ -365,7 +365,7 @@ async def test_sasl_plain(self):
authSource=SASL_DB,
authMechanism="PLAIN",
)
await client.ldap.test.find_one()
await client.ldap.coll.find_one()

uri = "mongodb://%s:%s@%s:%d/?authMechanism=PLAIN;authSource=%s;replicaSet=%s" % (
quote_plus(SASL_USER),
Expand All @@ -376,7 +376,7 @@ async def test_sasl_plain(self):
str(set_name),
)
client = self.simple_client(uri)
await client.ldap.test.find_one()
await client.ldap.coll.find_one()

async def test_sasl_plain_bad_credentials(self):
def auth_string(user, password):
Expand Down Expand Up @@ -654,13 +654,13 @@ async def test_cache(self):

@async_client_context.require_sync
async def test_scram_threaded(self):
coll = async_client_context.client.db.test
coll = async_client_context.client.db.coll
await coll.drop()
await coll.insert_one({"_id": 1})

# The first thread to call find() will authenticate
client = await self.async_rs_or_single_client()
coll = client.db.test
coll = client.db.coll
threads = []
for _ in range(4):
threads.append(AutoAuthenticateThread(coll))
Expand Down
Loading
Loading