Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

tests: exclude onnxruntime import-time warnings from the no-warnings gate (#3899)

Dmytro Mishkin3968012017ad
diff --git a/tests/test_import.py b/tests/test_import.py
index 52692264c..93908b816 100644
--- a/tests/test_import.py
+++ b/tests/test_import.py
@@ -70,12 +70,19 @@ def test_import_emits_no_warnings():
"""
script = textwrap.dedent(
"""
+ import contextlib
import warnings
warnings.resetwarnings()
import torch # noqa: F401 # torch's own import warnings are not kornia's to fix
+ # Same for onnxruntime, which kornia.feature.lightglue_onnx imports eagerly when
+ # installed: its import-time platform warnings (e.g. "Unsupported Windows version
+ # (2025server)" on windows-2025 runners) are not kornia's to fix either.
+ with contextlib.suppress(ImportError):
+ import onnxruntime # noqa: F401
+
warnings.simplefilter("error")
import kornia # noqa: F401
"""