Skip to content

Commit 6a672d4

Browse files
authored
PYTHON-5382 - Add a test with min dependencies (#2410)
1 parent 0cb4b2f commit 6a672d4

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.github/workflows/test-python.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,55 @@ jobs:
220220
which python
221221
pip install -e ".[test]"
222222
PYMONGO_MUST_CONNECT=1 pytest -v -k client_context
223+
224+
test_minimum:
225+
permissions:
226+
contents: read
227+
runs-on: ubuntu-latest
228+
name: Test using minimum dependencies and supported Python
229+
steps:
230+
- uses: actions/checkout@v4
231+
with:
232+
persist-credentials: false
233+
- name: Install uv
234+
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
235+
with:
236+
python-version: '3.9'
237+
- name: Start MongoDB
238+
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0
239+
with:
240+
mongodb-version: 6.0
241+
# Async and our test_dns do not support dnspython 1.X, so we don't run async or dns tests here
242+
- name: Run tests
243+
shell: bash
244+
run: |
245+
uv venv
246+
source .venv/bin/activate
247+
uv pip install -e ".[test]" --resolution=lowest-direct
248+
pytest -v test/test_srv_polling.py
249+
250+
test_minimum_for_async:
251+
permissions:
252+
contents: read
253+
runs-on: ubuntu-latest
254+
name: Test async's minimum dependencies and Python
255+
steps:
256+
- uses: actions/checkout@v4
257+
with:
258+
persist-credentials: false
259+
- name: Install uv
260+
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
261+
with:
262+
python-version: '3.9'
263+
- name: Start MongoDB
264+
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0
265+
with:
266+
mongodb-version: 6.0
267+
# The lifetime kwarg we use in srv resolution was added to the async resolver API in dnspython 2.1.0
268+
- name: Run tests
269+
shell: bash
270+
run: |
271+
uv venv
272+
source .venv/bin/activate
273+
uv pip install -e ".[test]" --resolution=lowest-direct dnspython==2.1.0 --force-reinstall
274+
pytest -v test/test_srv_polling.py test/test_dns.py test/asynchronous/test_srv_polling.py test/asynchronous/test_dns.py

test/asynchronous/test_srv_polling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def test_import_dns_resolver(self):
363363
# Regression test for PYTHON-4407
364364
import dns.resolver
365365

366-
self.assertTrue(hasattr(dns.resolver, "resolve"))
366+
self.assertTrue(hasattr(dns.resolver, "resolve") or hasattr(dns.resolver, "query"))
367367

368368

369369
if __name__ == "__main__":

test/test_srv_polling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def test_import_dns_resolver(self):
363363
# Regression test for PYTHON-4407
364364
import dns.resolver
365365

366-
self.assertTrue(hasattr(dns.resolver, "resolve"))
366+
self.assertTrue(hasattr(dns.resolver, "resolve") or hasattr(dns.resolver, "query"))
367367

368368

369369
if __name__ == "__main__":

0 commit comments

Comments
 (0)