We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent becc2b5 commit 4e1db14Copy full SHA for 4e1db14
tests/test_util_base.py
@@ -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