Skip to content
Open
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
2 changes: 1 addition & 1 deletion test/asynchronous/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2922,7 +2922,7 @@ async def encrypt_and_cast(i):
EncryptionError, "expected matching 'min' and value type. Got range option"
):
await self.client_encryption.encrypt(
6 if cast_func is int else float(6),
6 if cast_func is not int else float(6),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had this test been corrupted by the previous PR?

key_id=self.key1_id,
algorithm=Algorithm.RANGE,
contention_factor=0,
Expand Down
6 changes: 3 additions & 3 deletions test/asynchronous/test_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ async def test_no_wait_queue_timeout(self):
async with pool.checkout() as s1:
t = SocketGetter(self.c, pool)
await t.start()
while t.state != "get_socket": # noqa: ASYNC110
while t.state != "get_socket": # noqa: ASYNC110, RUF100
await asyncio.sleep(0.1)

await asyncio.sleep(1)
self.assertEqual(t.state, "get_socket")

while t.state != "connection": # noqa: ASYNC110
while t.state != "connection": # noqa: ASYNC110, RUF100
await asyncio.sleep(0.1)

self.assertEqual(t.state, "connection")
Expand Down Expand Up @@ -521,7 +521,7 @@ async def test_pool_backpressure_preserves_existing_connections(self):
await coll.insert_many([{"x": 1} for _ in range(10)])
t = SocketGetter(self.c, pool)
await t.start()
while t.state != "connection": # noqa: ASYNC110
while t.state != "connection": # noqa: ASYNC110, RUF100
await asyncio.sleep(0.1)

assert not t.sock.conn_closed()
Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/utils_spec_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def _create_tests(self):
dirname = os.path.split(dirpath)[-1]

for filename in filenames:
with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: ASYNC230
with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: ASYNC230, RUF100
# Use tz_aware=False to match how CodecOptions decodes
# dates.
opts = json_util.JSONOptions(tz_aware=False)
Expand Down
2 changes: 1 addition & 1 deletion test/test_client_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_doesnt_update_established_connections(self):
)

# send initial metadata
name, version, platform, _ = self.send_ping_and_get_metadata(client, True)
name, version, platform, _metadata = self.send_ping_and_get_metadata(client, True)
self.assertIsNotNone(name)
self.assertIsNotNone(version)
self.assertIsNotNone(platform)
Expand Down
6 changes: 3 additions & 3 deletions test/test_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ def test_no_wait_queue_timeout(self):
with pool.checkout() as s1:
t = SocketGetter(self.c, pool)
t.start()
while t.state != "get_socket":
while t.state != "get_socket": # noqa: ASYNC110, RUF100
time.sleep(0.1)

time.sleep(1)
self.assertEqual(t.state, "get_socket")

while t.state != "connection":
while t.state != "connection": # noqa: ASYNC110, RUF100
time.sleep(0.1)

self.assertEqual(t.state, "connection")
Expand Down Expand Up @@ -519,7 +519,7 @@ def test_pool_backpressure_preserves_existing_connections(self):
coll.insert_many([{"x": 1} for _ in range(10)])
t = SocketGetter(self.c, pool)
t.start()
while t.state != "connection":
while t.state != "connection": # noqa: ASYNC110, RUF100
time.sleep(0.1)

assert not t.sock.conn_closed()
Expand Down
2 changes: 1 addition & 1 deletion test/utils_spec_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def _create_tests(self):
dirname = os.path.split(dirpath)[-1]

for filename in filenames:
with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: RUF100
with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: ASYNC230, RUF100
# Use tz_aware=False to match how CodecOptions decodes
# dates.
opts = json_util.JSONOptions(tz_aware=False)
Expand Down
28 changes: 8 additions & 20 deletions tools/synchro.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,14 @@
if not Path.exists(Path(_gridfs_dest_base)):
Path.mkdir(Path(_gridfs_dest_base))

async_files = [
_pymongo_base + str(f)
for f in Path.iterdir(Path(_pymongo_base))
if (Path(_pymongo_base) / f).is_file()
]
async_files = [_pymongo_base + f.name for f in Path(_pymongo_base).iterdir() if f.is_file()]

gridfs_files = [
_gridfs_base + str(f)
for f in Path.iterdir(Path(_gridfs_base))
if (Path(_gridfs_base) / f).is_file()
]
gridfs_files = [_gridfs_base + f.name for f in Path(_gridfs_base).iterdir() if f.is_file()]


def async_only_test(f: Path) -> bool:
"""Return True for async tests that should not be converted to sync."""
return str(f) in [
return f.name in [
"test_locks.py",
"test_concurrency.py",
"test_async_cancellation.py",
Expand All @@ -197,9 +189,9 @@ def async_only_test(f: Path) -> bool:


test_files = [
_test_base + str(f)
for f in Path.iterdir(Path(_test_base))
if (Path(_test_base) / f).is_file() and not async_only_test(f)
_test_base + f.name
for f in Path(_test_base).iterdir()
if f.is_file() and not async_only_test(f)
]

# Add each asynchronized test here as part of the converting PR
Expand Down Expand Up @@ -453,15 +445,11 @@ def main() -> None:
unasync_directory(test_files, _test_base, _test_dest_base, replacements)

sync_files = [
_pymongo_dest_base + str(f)
for f in Path.iterdir(Path(_pymongo_dest_base))
if (Path(_pymongo_dest_base) / f).is_file()
_pymongo_dest_base + f.name for f in Path(_pymongo_dest_base).iterdir() if f.is_file()
]

sync_gridfs_files = [
_gridfs_dest_base + str(f)
for f in Path.iterdir(Path(_gridfs_dest_base))
if (Path(_gridfs_dest_base) / f).is_file()
_gridfs_dest_base + f.name for f in Path(_gridfs_dest_base).iterdir() if f.is_file()
]
sync_test_files = [
_test_dest_base + f for f in converted_tests if (Path(_test_dest_base) / f).is_file()
Expand Down
Loading