Skip to content

Commit

Permalink
run-tests.sh fix for async
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp committed Jan 24, 2025
1 parent 8602dde commit cc3f1ad
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
15 changes: 7 additions & 8 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,21 @@ if [ -z "$GREEN_FRAMEWORK" ]; then
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
PYTEST_ARGS="-v --capture=tee-sys --durations=5 $TEST_ARGS"
if [ -n "$TEST_SUITES" ]; then
# Workaround until unittest -> pytest conversion is complete
# shellcheck disable=SC2206
ASYNC_PYTEST_ARGS=("-m asyncio and $TEST_SUITES" "--junitxml=xunit-results/TEST-asyncresults.xml" $PYTEST_ARGS)
PYTEST_ARGS="-m $TEST_SUITES $PYTEST_ARGS"
fi
# shellcheck disable=SC2048
uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS

# Workaround until unittest -> pytest conversion is complete
if [ -z "$TEST_SUITES" ]; then
PYTEST_ARGS="-m asyncio --junitxml=xunit-results/TEST-asyncresults.xml $PYTEST_ARGS"
# shellcheck disable=SC2048
uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS
else
PYTEST_ARGS="-m $TEST_SUITES and asyncio --junitxml=xunit-results/TEST-asyncresults.xml $PYTEST_ARGS"
# shellcheck disable=SC2048
uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS
# shellcheck disable=SC2206
ASYNC_PYTEST_ARGS=("-m asyncio" "--junitxml=xunit-results/TEST-asyncresults.xml" $PYTEST_ARGS)
fi

# shellcheck disable=SC2048
uv run ${UV_ARGS[*]} pytest "${ASYNC_PYTEST_ARGS[@]}"
else
# shellcheck disable=SC2048
uv run ${UV_ARGS[*]} green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS
Expand Down
1 change: 1 addition & 0 deletions pymongo/asynchronous/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ def __next__(self) -> NoReturn:
next = __next__
if not _IS_SYNC:
anext = next
__anext__ = next

async def _server_property(self, attr_name: str) -> Any:
"""An attribute of the current server's description.
Expand Down
1 change: 1 addition & 0 deletions pymongo/synchronous/mongo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ def __next__(self) -> NoReturn:
next = __next__
if not _IS_SYNC:
next = next
__next__ = next

def _server_property(self, attr_name: str) -> Any:
"""An attribute of the current server's description.
Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ async def test_getattr(self, async_client):
assert "has no attribute '_does_not_exist'" in str(context.value)

async def test_iteration(self, async_client):
if _IS_SYNC:
if _IS_SYNC or sys.version_info < (3, 10):
msg = "'AsyncMongoClient' object is not iterable"
else:
msg = "'AsyncMongoClient' object is not an async iterator"
Expand Down
2 changes: 1 addition & 1 deletion test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_getattr(self, client):
assert "has no attribute '_does_not_exist'" in str(context.value)

def test_iteration(self, client):
if _IS_SYNC:
if _IS_SYNC or sys.version_info < (3, 10):
msg = "'MongoClient' object is not iterable"
else:
msg = "'MongoClient' object is not an async iterator"
Expand Down

0 comments on commit cc3f1ad

Please sign in to comment.