From 5ec832fb82335d062d2b469ce3200b94903cb0b4 Mon Sep 17 00:00:00 2001 From: gargsaumya Date: Tue, 16 Jun 2026 09:58:28 +0530 Subject: [PATCH] Fix pytest 9.1 importorskip collection error in test_019_bulkcopy pytest 9.1 changed importorskip's default exc_type from ImportError to ModuleNotFoundError. mssql_py_core is found but its native .so can fail to load (e.g. missing libssl.so.3) raising a plain ImportError, which 9.1 re-raises as a collection error instead of skipping. Pass exc_type=ImportError to restore skip-on-load-failure, and drop the hardcoded reason so pytest reports the actual import error. --- tests/test_019_bulkcopy.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_019_bulkcopy.py b/tests/test_019_bulkcopy.py index c03d85ae..705e9263 100644 --- a/tests/test_019_bulkcopy.py +++ b/tests/test_019_bulkcopy.py @@ -5,10 +5,16 @@ import pytest -# Skip the entire module when mssql_py_core can't be loaded at runtime -# (e.g. manylinux_2_28 build containers where glibc is too old for the .so). +# Skip the entire module when mssql_py_core can't be loaded (e.g. it's not +# installed, or its native extension fails to load in some build containers). +# exc_type=ImportError is required because pytest 9.1 changed importorskip's +# default to only skip on ModuleNotFoundError, so a module that is found but +# fails to import its native extension would otherwise be raised as a collection +# error instead of being skipped. The skip reason is left to pytest so it +# reports the actual underlying import error. mssql_py_core = pytest.importorskip( - "mssql_py_core", reason="mssql_py_core not loadable (glibc too old?)" + "mssql_py_core", + exc_type=ImportError, )