Skip to content

Commit 2d7913b

Browse files
committed
fix handling of collection
1 parent 64416b5 commit 2d7913b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

test/asynchronous/test_cursor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ async def test_explain_csot(self):
368368
client = await self.async_rs_or_single_client(event_listeners=[listener])
369369

370370
# Create a collection, referred to as collection, with the namespace explain-test.collection.
371-
collection = await client["explain-test"].create_collection("collection")
371+
names = await client["explain-test"].list_collection_names()
372+
if "collection" not in names:
373+
collection = await client["explain-test"].create_collection("collection")
374+
else:
375+
collection = client["explain-test"]["collection"]
372376

373377
# Run an explained find on collection. The find will have the query predicate { name: 'john doe' }. Specify a maxTimeMS value of 2000ms for the explain.
374378
with pymongo.timeout(2.0):

test/test_cursor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ def test_explain_csot(self):
360360
client = self.rs_or_single_client(event_listeners=[listener])
361361

362362
# Create a collection, referred to as collection, with the namespace explain-test.collection.
363-
collection = client["explain-test"].create_collection("collection")
363+
names = client["explain-test"].list_collection_names()
364+
if "collection" not in names:
365+
collection = client["explain-test"].create_collection("collection")
366+
else:
367+
collection = client["explain-test"]["collection"]
364368

365369
# Run an explained find on collection. The find will have the query predicate { name: 'john doe' }. Specify a maxTimeMS value of 2000ms for the explain.
366370
with pymongo.timeout(2.0):

0 commit comments

Comments
 (0)