Skip to content

PYTHON-5796: Reduce insert_one({}) collection-priming calls in test suite#2855

Open
sophiayangDB wants to merge 4 commits into
mongodb:masterfrom
sophiayangDB:PYTHON-5796
Open

PYTHON-5796: Reduce insert_one({}) collection-priming calls in test suite#2855
sophiayangDB wants to merge 4 commits into
mongodb:masterfrom
sophiayangDB:PYTHON-5796

Conversation

@sophiayangDB
Copy link
Copy Markdown
Contributor

@sophiayangDB sophiayangDB commented Jun 5, 2026

PYTHON-5796

Changes in this PR

  • Replace insert_one({}) with explicit create_collection() calls where the intent is solely to test against an existing collection
  • When possible, add collection step to setUp/asyncSetUp on relevant base classes

Test Plan

Only modified test files.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sophiayangDB sophiayangDB marked this pull request as ready for review June 5, 2026 15:02
@sophiayangDB sophiayangDB requested a review from a team as a code owner June 5, 2026 15:02
@sophiayangDB
Copy link
Copy Markdown
Contributor Author

MacOS test failures are unrelated

async def test_case_1(self):
"""Driver can successfully create and list search indexes."""

# Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await self.client.pymongo_test.create_collection("test")

async def asyncTearDown(self):
await self.client.pymongo_test.drop_collection("test")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick / minor comment: does the drop collection need to be here if its also already done in the asyncSetup?

Comment thread test/test_cursor.py
self.db.test.find_raw_batches()[0]

def test_collation(self):
self.db.test.insert_one({})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silly question: should this be a create collection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants