-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5550 Add a test that uses uvloop as the event loop #2543
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
Changes from 2 commits
359aca7
7f8006a
16ee095
01289b0
8e108fb
38a4fb6
d6c6a15
bc0c118
e3b6ec6
1fae50e
3efdf46
46ea22c
aaba58b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,8 @@ | |
version: "${{ matrix.mongodb-version }}" | ||
- name: Run tests | ||
run: uv run --extra test pytest -v | ||
- name: Run uvloop test | ||
run: uv run tools/test_uv_loop.py | ||
|
||
doctest: | ||
runs-on: ubuntu-latest | ||
|
@@ -163,6 +165,30 @@ | |
run: | | ||
just typing | ||
integration_tets: | ||
runs-on: ubuntu-latest | ||
name: Integration Tests | ||
steps: | ||
- uses: actions/checkout@v5 | ||
with: | ||
persist-credentials: false | ||
- name: Install uv | ||
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5 | ||
with: | ||
enable-cache: true | ||
python-version: "3.9" | ||
|
||
- name: Install just | ||
run: uv tool install rust-just | ||
- id: setup-mongodb | ||
uses: mongodb-labs/drivers-evergreen-tools@master | ||
|
||
with: | ||
version: "8.0" | ||
- name: Install dependencies | ||
run: just install | ||
- name: Run tests | ||
run: | | ||
just integration-tests | ||
|
||
make_sdist: | ||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium test
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
|
||
runs-on: ubuntu-latest | ||
name: "Make an sdist" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Integration Tests | ||
|
||
A set of tests that verify the usage of PyMongo with downstream packages or frameworks. | ||
|
||
Each test uses [PEP 723 inline metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/) and can be run using `pipx` or `uv`. | ||
|
||
The `run.sh` convenience script can be used to run all of the files using `uv`. | ||
|
||
When creating a new script, use the following snippet to ensure that the local version of PyMongo is used: | ||
|
||
|
||
```python | ||
# Use pymongo from parent directory. | ||
import sys | ||
from pathlib import Path | ||
|
||
root = Path(__file__).parent.parent | ||
sys.path.insert(0, str(root)) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
# Run all of the integration test files using `uv run`. | ||
set -eu | ||
|
||
HERE=$(dirname ${BASH_SOURCE:-$0}) | ||
pushd "$HERE" > /dev/null | ||
trap 'popd' ERR | ||
|
||
for file in test_*.py ; do | ||
echo "-----------------" | ||
echo "Running $file..." | ||
uv run $file | ||
echo "Running $file...done." | ||
echo "-----------------" | ||
done | ||
|
||
popd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# /// script | ||
# dependencies = [ | ||
# "uvloop>=0.18" | ||
# ] | ||
# requires-python = ">=3.10" | ||
# /// | ||
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
import uvloop | ||
|
||
# Use pymongo from parent directory. | ||
root = Path(__file__).parent.parent | ||
sys.path.insert(0, str(root)) | ||
|
||
from pymongo import AsyncMongoClient # noqa: E402 | ||
|
||
|
||
async def main(): | ||
client = AsyncMongoClient() | ||
result = await client.admin.command("ping") | ||
assert result["ok"] | ||
|
||
|
||
uvloop.run(main()) |
Uh oh!
There was an error while loading. Please reload this page.