Skip to content

Commit cc3f1ad

Browse files
committed
run-tests.sh fix for async
1 parent 8602dde commit cc3f1ad

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

.evergreen/run-tests.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,21 @@ if [ -z "$GREEN_FRAMEWORK" ]; then
267267
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
268268
PYTEST_ARGS="-v --capture=tee-sys --durations=5 $TEST_ARGS"
269269
if [ -n "$TEST_SUITES" ]; then
270+
# Workaround until unittest -> pytest conversion is complete
271+
# shellcheck disable=SC2206
272+
ASYNC_PYTEST_ARGS=("-m asyncio and $TEST_SUITES" "--junitxml=xunit-results/TEST-asyncresults.xml" $PYTEST_ARGS)
270273
PYTEST_ARGS="-m $TEST_SUITES $PYTEST_ARGS"
271274
fi
272275
# shellcheck disable=SC2048
273276
uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS
274277

275278
# Workaround until unittest -> pytest conversion is complete
276279
if [ -z "$TEST_SUITES" ]; then
277-
PYTEST_ARGS="-m asyncio --junitxml=xunit-results/TEST-asyncresults.xml $PYTEST_ARGS"
278-
# shellcheck disable=SC2048
279-
uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS
280-
else
281-
PYTEST_ARGS="-m $TEST_SUITES and asyncio --junitxml=xunit-results/TEST-asyncresults.xml $PYTEST_ARGS"
282-
# shellcheck disable=SC2048
283-
uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS
280+
# shellcheck disable=SC2206
281+
ASYNC_PYTEST_ARGS=("-m asyncio" "--junitxml=xunit-results/TEST-asyncresults.xml" $PYTEST_ARGS)
284282
fi
285-
283+
# shellcheck disable=SC2048
284+
uv run ${UV_ARGS[*]} pytest "${ASYNC_PYTEST_ARGS[@]}"
286285
else
287286
# shellcheck disable=SC2048
288287
uv run ${UV_ARGS[*]} green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS

pymongo/asynchronous/mongo_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,7 @@ def __next__(self) -> NoReturn:
14201420
next = __next__
14211421
if not _IS_SYNC:
14221422
anext = next
1423+
__anext__ = next
14231424

14241425
async def _server_property(self, attr_name: str) -> Any:
14251426
"""An attribute of the current server's description.

pymongo/synchronous/mongo_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ def __next__(self) -> NoReturn:
14161416
next = __next__
14171417
if not _IS_SYNC:
14181418
next = next
1419+
__next__ = next
14191420

14201421
def _server_property(self, attr_name: str) -> Any:
14211422
"""An attribute of the current server's description.

test/asynchronous/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ async def test_getattr(self, async_client):
243243
assert "has no attribute '_does_not_exist'" in str(context.value)
244244

245245
async def test_iteration(self, async_client):
246-
if _IS_SYNC:
246+
if _IS_SYNC or sys.version_info < (3, 10):
247247
msg = "'AsyncMongoClient' object is not iterable"
248248
else:
249249
msg = "'AsyncMongoClient' object is not an async iterator"

test/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def test_getattr(self, client):
240240
assert "has no attribute '_does_not_exist'" in str(context.value)
241241

242242
def test_iteration(self, client):
243-
if _IS_SYNC:
243+
if _IS_SYNC or sys.version_info < (3, 10):
244244
msg = "'MongoClient' object is not iterable"
245245
else:
246246
msg = "'MongoClient' object is not an async iterator"

0 commit comments

Comments
 (0)