-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4737 Migrate test_binary.py to async #1863
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
Conversation
test/asynchronous/test_client.py
Outdated
@@ -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 = ( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, good call!
test/asynchronous/test_client.py
Outdated
from unittest import mock | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
import pytest_asyncio | ||
|
||
from bson.binary import * |
There was a problem hiding this comment.
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
test/asynchronous/test_client.py
Outdated
@@ -57,6 +60,7 @@ | |||
unittest, | |||
) | |||
from test.asynchronous.pymongo_mocks import AsyncMockClient | |||
from test.test_binary import TestBinary |
There was a problem hiding this comment.
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.
test/asynchronous/test_client.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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_connection
s now that this is in test_client.
My brain forgot to check up on this until now haha, but thanks for the feedback! I think I made the appropriate changes :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch! I'll try something else! |
…ary tests from running on import in test client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
More like test_binary shouldn't have any client stuff in it....I've moved tests that require the client from
test_binary.py
totest_client.py