@@ -38,10 +38,23 @@ def test_register_component():
3838 path = os .path .join (path , 'registerFilesIop' )
3939 overwrite = 1
4040 iris_classname = 'UnitTest.EmailOperation'
41- result = _Utils .register_component (module , classname , path , overwrite , iris_classname )
42- expect = 1
41+ _Utils .register_component (module , classname , path , overwrite , iris_classname )
4342
44- assert result == expect
43+ def test_register_module_error ():
44+ module = 'bo'
45+ classname = 'EmailOperation'
46+ # get the path of the current file
47+ path = os .path .dirname (os .path .realpath (__file__ ))
48+ # join the registerFolder to the path
49+ path = os .path .join (path , 'registerFilesIop' )
50+ overwrite = 1
51+ # mock call iris.cls() to raise an exception
52+ with patch ('iris.cls' , side_effect = RuntimeError ):
53+ iris_classname = 'UnitTest.EmailOperation'
54+ try :
55+ _Utils .register_component (module , classname , path , overwrite , iris_classname )
56+ except RuntimeError as e :
57+ assert True
4558
4659def test_register_folder ():
4760 path = os .path .dirname (os .path .realpath (__file__ ))
0 commit comments