Skip to content
Merged
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
6 changes: 3 additions & 3 deletions test/asynchronous/test_client_bulk_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import os
import sys

from pymongo.operations import InsertOne, ReplaceOne, UpdateOne

sys.path[0:0] = [""]

from unittest.mock import patch
Expand All @@ -32,14 +34,12 @@
InvalidOperation,

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.

Maybe we should leave this explicit import because without it it's only covered by from pymongo.operations import * accidentally. InvalidOperation still appears to be in use on lines 52 and 535.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If it's being imported somehow and the file doesn't fail to run then I don't see the need for a second explicit import.

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.

The reason is (leaving aside the "code smell" of * imports …) from pymongo.operations import * is (typically) for things in pymongo.operations and so if operations one day decides to not import InvalidOperation then this test unexpectedly breaks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved by removing the * import entirely and explicitly importing instead.

NetworkTimeout,
)
from pymongo.operations import *
from pymongo.write_concern import WriteConcern
from test.asynchronous import (
AsyncIntegrationTest,
async_client_context,
unittest,
)
from test.asynchronous.utils import flaky
from test.utils_shared import (
OvertCommandListener,
)
Expand Down Expand Up @@ -634,7 +634,7 @@ async def asyncSetUp(self):

@async_client_context.require_version_min(8, 0, 0, -24)
@async_client_context.require_failCommand_fail_point
@flaky(reason="PYTHON-5290", max_runs=3, affects_cpython_linux=True)
@async_client_context.require_standalone
async def test_timeout_in_multi_batch_bulk_write(self):
Comment on lines 635 to 638
if sys.platform != "linux" and "CI" in os.environ:
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows and MacOS")
Expand Down
6 changes: 3 additions & 3 deletions test/test_client_bulk_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import os
import sys

from pymongo.operations import InsertOne, ReplaceOne, UpdateOne

sys.path[0:0] = [""]

from unittest.mock import patch
Expand All @@ -31,15 +33,13 @@
InvalidOperation,
NetworkTimeout,
)
from pymongo.operations import *
from pymongo.synchronous.client_bulk import _ClientBulk
from pymongo.write_concern import WriteConcern
from test import (
IntegrationTest,
client_context,
unittest,
)
from test.utils import flaky
from test.utils_shared import (
OvertCommandListener,
)
Expand Down Expand Up @@ -630,7 +630,7 @@ def setUp(self):

@client_context.require_version_min(8, 0, 0, -24)
@client_context.require_failCommand_fail_point
@flaky(reason="PYTHON-5290", max_runs=3, affects_cpython_linux=True)
@client_context.require_standalone
def test_timeout_in_multi_batch_bulk_write(self):
Comment on lines 631 to 634
if sys.platform != "linux" and "CI" in os.environ:
self.skipTest("PYTHON-3522 CSOT test runs too slow on Windows and MacOS")
Expand Down
Loading