Skip to content

Commit afdf08b

Browse files
committed
Add test for try import function
1 parent 6b883e0 commit afdf08b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from jax.test_util import check_grads
77

88
from s2fft.sampling import s2_samples as samples
9+
from s2fft.transforms.c_backend_spherical import (
10+
MissingWrapperDependencyError,
11+
_try_import_module,
12+
)
913
from s2fft.utils.rotation import generate_rotate_dls, rotate_flms
1014

1115
jax.config.update("jax_enable_x64", True)
@@ -120,3 +124,12 @@ def func(flm):
120124
return jnp.sum(jnp.abs(flm_rot - flm_target))
121125

122126
check_grads(func, (flm_start,), order=1, modes=("rev"))
127+
128+
129+
def test_try_import_module():
130+
# Use an intentionally long and unlikely to clash module name
131+
module_name = "_a_random_module_name_that_should_not_exist"
132+
with pytest.raises(
133+
MissingWrapperDependencyError, match="requires {module_name} to be installed"
134+
):
135+
_try_import_module(module_name)

0 commit comments

Comments
 (0)