Skip to content

Commit

Permalink
Add unit test for is_available()
Browse files Browse the repository at this point in the history
  • Loading branch information
gigony committed Sep 29, 2021
1 parent 4d87631 commit d46d49f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
45 changes: 45 additions & 0 deletions python/cucim/tests/unit/test_init.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down

0 comments on commit d46d49f

Please sign in to comment.