diff --git a/tests/onnxruntime/test_modeling.py b/tests/onnxruntime/test_modeling.py index 71d36260b3f..ed5b1b3158c 100644 --- a/tests/onnxruntime/test_modeling.py +++ b/tests/onnxruntime/test_modeling.py @@ -357,12 +357,11 @@ def test_missing_execution_provider(self): if not is_onnxruntime_gpu_installed: for provider in ["CUDAExecutionProvider", "TensorrtExecutionProvider"]: - with self.assertRaises(ImportError) as cm: + with self.assertRaises(ValueError) as cm: _ = ORTModel.from_pretrained(self.ONNX_MODEL_ID, provider=provider) - self.assertTrue( - f"Asked to use {provider}, but `onnxruntime-gpu` package was not found." in str(cm.exception) - ) + self.assertTrue("but the available execution providers" in str(cm.exception)) + else: logger.info("Skipping CUDAExecutionProvider/TensorrtExecutionProvider without `onnxruntime-gpu` test") @@ -370,12 +369,10 @@ def test_missing_execution_provider(self): # thus overwritting onnxruntime/capi/_ld_preload.py if is_onnxruntime_installed and is_onnxruntime_gpu_installed: for provider in ["CUDAExecutionProvider", "TensorrtExecutionProvider"]: - with self.assertRaises(ImportError) as cm: + with self.assertRaises(ValueError) as cm: _ = ORTModel.from_pretrained(self.ONNX_MODEL_ID, provider=provider) - self.assertTrue( - "`onnxruntime-gpu` is installed, but GPU dependencies are not loaded." in str(cm.exception) - ) + self.assertTrue("but the available execution providers" in str(cm.exception)) else: logger.info("Skipping double onnxruntime + onnxruntime-gpu install test")