From 34f15fd34f8712a34cb1969f5b1a356ef0e959bf Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 11 Feb 2026 07:42:35 -0600 Subject: [PATCH] fix pyopenssl and numpy --- .evergreen/generated_configs/functions.yml | 1 + .evergreen/scripts/generate_config.py | 2 +- justfile | 6 +++++- test/asynchronous/test_ssl.py | 17 ++--------------- test/test_ssl.py | 17 ++--------------- 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/.evergreen/generated_configs/functions.yml b/.evergreen/generated_configs/functions.yml index 5998fd715..9fbc1f850 100644 --- a/.evergreen/generated_configs/functions.yml +++ b/.evergreen/generated_configs/functions.yml @@ -250,6 +250,7 @@ functions: working_dir: src include_expansions_in_env: - TOOLCHAIN_VERSION + - COVERAGE type: test # Upload coverage codecov diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index a5cb7bc03..b9979341b 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -1246,7 +1246,7 @@ def create_run_tests_func(): def create_test_numpy_func(): - includes = ["TOOLCHAIN_VERSION"] + includes = ["TOOLCHAIN_VERSION", "COVERAGE"] test_cmd = get_subprocess_exec( include_expansions_in_env=includes, args=[".evergreen/just.sh", "test-numpy"] ) diff --git a/justfile b/justfile index 082b6ea17..96a60d711 100644 --- a/justfile +++ b/justfile @@ -61,7 +61,11 @@ test *args="-v --durations=5 --maxfail=10": && resync [group('test')] test-numpy: && resync - uv run --extra test --with numpy python -m pytest test/test_bson.py + if [ "{{COVERAGE}}" = "1" ]; then \ + uv run --extra test --group coverage --with numpy python -m pytest --cov test/test_bson.py; \ + else \ + uv run --extra test --with numpy python -m pytest test/test_bson.py; \ + fi [group('test')] run-tests *args: && resync diff --git a/test/asynchronous/test_ssl.py b/test/asynchronous/test_ssl.py index 0ce3e8bba..7fe57e850 100644 --- a/test/asynchronous/test_ssl.py +++ b/test/asynchronous/test_ssl.py @@ -48,19 +48,11 @@ from pymongo.write_concern import WriteConcern _HAVE_PYOPENSSL = False try: - # All of these must be available to use PyOpenSSL - import OpenSSL - import requests - import service_identity - - # Ensure service_identity>=18.1 is installed - from service_identity.pyopenssl import verify_ip_address - - from pymongo.ocsp_support import _load_trusted_ca_certs + from pymongo import pyopenssl_context _HAVE_PYOPENSSL = True except ImportError: - _load_trusted_ca_certs = None # type: ignore + pass if HAVE_SSL: @@ -136,11 +128,6 @@ class TestClientSSL(AsyncPyMongoTestCase): def test_use_pyopenssl_when_available(self): self.assertTrue(HAVE_PYSSL) - @unittest.skipUnless(_HAVE_PYOPENSSL, "Cannot test without PyOpenSSL") - def test_load_trusted_ca_certs(self): - trusted_ca_certs = _load_trusted_ca_certs(CA_BUNDLE_PEM) - self.assertEqual(2, len(trusted_ca_certs)) - class TestSSL(AsyncIntegrationTest): saved_port: int diff --git a/test/test_ssl.py b/test/test_ssl.py index b1e9a65eb..77bb086ec 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -48,19 +48,11 @@ from pymongo.write_concern import WriteConcern _HAVE_PYOPENSSL = False try: - # All of these must be available to use PyOpenSSL - import OpenSSL - import requests - import service_identity - - # Ensure service_identity>=18.1 is installed - from service_identity.pyopenssl import verify_ip_address - - from pymongo.ocsp_support import _load_trusted_ca_certs + from pymongo import pyopenssl_context _HAVE_PYOPENSSL = True except ImportError: - _load_trusted_ca_certs = None # type: ignore + pass if HAVE_SSL: @@ -136,11 +128,6 @@ class TestClientSSL(PyMongoTestCase): def test_use_pyopenssl_when_available(self): self.assertTrue(HAVE_PYSSL) - @unittest.skipUnless(_HAVE_PYOPENSSL, "Cannot test without PyOpenSSL") - def test_load_trusted_ca_certs(self): - trusted_ca_certs = _load_trusted_ca_certs(CA_BUNDLE_PEM) - self.assertEqual(2, len(trusted_ca_certs)) - class TestSSL(IntegrationTest): saved_port: int