Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON-4737 Migrate test_binary.py to async #1863

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sleepyStick
Copy link
Contributor

More like test_binary shouldn't have any client stuff in it....I've moved tests that require the client from test_binary.py to test_client.py

@sleepyStick sleepyStick marked this pull request as ready for review September 17, 2024 23:03
@@ -2020,6 +2023,110 @@ def test_dict_hints_sort(self):
async def test_dict_hints_create_index(self):
await self.db.t.create_index({"x": pymongo.ASCENDING})

@async_client_context.require_connection
async def test_legacy_java_uuid_roundtrip(self):
from_java = (
Copy link
Member

Choose a reason for hiding this comment

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

Any way we can share this blob with test_binary? Same for from_csharp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, good call!

from unittest import mock
from unittest.mock import patch

import pytest
import pytest_asyncio

from bson.binary import *
Copy link
Member

Choose a reason for hiding this comment

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

We try to avoid * imports for a few reasons: https://stackoverflow.com/questions/2386714/why-is-import-bad

@@ -57,6 +60,7 @@
unittest,
)
from test.asynchronous.pymongo_mocks import AsyncMockClient
from test.test_binary import TestBinary
Copy link
Member

Choose a reason for hiding this comment

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

Importing TestBinary directly will actually cause pytest/unittest to pick up and run TestBinary in this file too. Instead we need to mangle to name, like: from test.test_binary import TestBinary as BinaryBase or move the test data out of TestBinary into to a global var that we can import.

@@ -2020,6 +2024,78 @@ def test_dict_hints_sort(self):
async def test_dict_hints_create_index(self):
await self.db.t.create_index({"x": pymongo.ASCENDING})

@async_client_context.require_connection
Copy link
Member

Choose a reason for hiding this comment

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

I beleive we can remove the require_connections now that this is in test_client.

@sleepyStick
Copy link
Contributor Author

My brain forgot to check up on this until now haha, but thanks for the feedback! I think I made the appropriate changes :)

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.

2 participants