Skip to content

Commit 4e1db14

Browse files
Add test coverage for new type of exception
Signed-off-by: Maksym Kovalchuk <mkovalchuk@nvidia.com>
1 parent becc2b5 commit 4e1db14

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_util_base.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from unittest.mock import patch, MagicMock
2+
from utilities_common.util_base import UtilHelper
3+
4+
5+
@patch("pkgutil.iter_modules")
6+
@patch("utilities_common.util_base.log.log_warning")
7+
def test_module_not_found_error(mock_log_warning, mock_iter_modules):
8+
non_existent_module_name = "non-existent-module"
9+
10+
mock_iter_modules.return_value = [(None, non_existent_module_name, False)]
11+
12+
plugins_namespace = MagicMock()
13+
plugins_namespace.__path__ = "some_path"
14+
plugins_namespace.__name__ = "some_name"
15+
16+
list(UtilHelper().load_plugins(plugins_namespace))
17+
18+
mock_log_warning.assert_called_once_with("failed to import plugin {0}: No module named '{0}'"
19+
.format(non_existent_module_name), also_print_to_console=True)

0 commit comments

Comments
 (0)