diff --git a/python/cucim/tests/unit/test_init.py b/python/cucim/tests/unit/test_init.py new file mode 100644 index 000000000..6cd7d5fd9 --- /dev/null +++ b/python/cucim/tests/unit/test_init.py @@ -0,0 +1,45 @@ +# +# Copyright (c) 2021, NVIDIA CORPORATION. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from unittest.mock import patch + + +def test_is_available(): + with patch('cucim._is_cupy_available', False): + with patch('cucim._is_clara_available', False): + import cucim + assert cucim.is_available() is False + assert cucim.is_available("skimage") is False + assert cucim.is_available("clara") is False + assert cucim.is_available("unknown") is False + with patch('cucim._is_clara_available', True): + import cucim + assert cucim.is_available() is False + assert cucim.is_available("skimage") is False + assert cucim.is_available("clara") is True + assert cucim.is_available("unknown") is False + + with patch('cucim._is_cupy_available', True): + with patch('cucim._is_clara_available', False): + import cucim + assert cucim.is_available() is False + assert cucim.is_available("skimage") is True + assert cucim.is_available("clara") is False + assert cucim.is_available("unknown") is False + with patch('cucim._is_clara_available', True): + import cucim + assert cucim.is_available() is True + assert cucim.is_available("skimage") is True + assert cucim.is_available("clara") is True + assert cucim.is_available("unknown") is True diff --git a/run b/run index 9ef6401e8..528aa553c 100755 --- a/run +++ b/run @@ -720,7 +720,7 @@ test_python() { local testsuite="" local testsuite_unit_skimage="src" - local testsuite_unit_clara="tests/unit/clara" + local testsuite_unit_clara="tests/unit" local testsuite_performance="tests/performance" install_python_test_deps_