File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -632,9 +632,8 @@ def _import_native_namespace(module_name: str) -> ModuleType:
632632def backend_version (implementation : Implementation , / ) -> tuple [int , ...]:
633633 if not isinstance (implementation , Implementation ):
634634 assert_never (implementation )
635- if implementation is Implementation .UNKNOWN : # pragma: no cover
636- msg = "Cannot return backend version from UNKNOWN Implementation"
637- raise AssertionError (msg )
635+ if implementation is Implementation .UNKNOWN :
636+ return (0 , 0 , 0 )
638637 into_version : ModuleType | str
639638 impl = implementation
640639 module_name = _IMPLEMENTATION_TO_MODULE_NAME .get (impl , impl .value )
Original file line number Diff line number Diff line change @@ -52,3 +52,20 @@ def test_to_native_namespace_unknown() -> None:
5252 AssertionError , match = "Cannot return native namespace from UNKNOWN Implementation"
5353 ):
5454 impl .to_native_namespace ()
55+
56+
57+ @pytest .mark .parametrize ("impl" , list (Implementation ))
58+ def test_backend_version (impl : Implementation ) -> None :
59+ version : tuple [int , ...] | None
60+ try :
61+ version = impl ._backend_version ()
62+ except (ModuleNotFoundError , ValueError ) as err :
63+ # NOTE: See https://github.com/narwhals-dev/narwhals/issues/2786
64+ assert impl is not Implementation .UNKNOWN
65+
66+ with pytest .raises (type (err )):
67+ impl .to_native_namespace ()
68+ version = None
69+
70+ if version is not None :
71+ assert version >= (0 , 0 , 0 )
You can’t perform that action at this time.
0 commit comments