#NEWLINE# @ mock . patch ( 'importlib.import_module' ) #NEWLINE# def test_command_use_01( self , mocked_import_module ) : #NEWLINE# #INDENT# ' Testing command_use()\n\n        * Known Exploit\n        * Known module\n        ' #NEWLINE# module_path = 'exploits/foo/bar' #NEWLINE# self . interpreter . current_module = None #NEWLINE# self . interpreter . modules = [ module_path , 'doo/pa/foo/bar' ] #NEWLINE# exploit_class = mock . MagicMock ( name = 'password_disclosure_module' ) #NEWLINE# mocked_import_module . return_value = mocked_module = mock . MagicMock ( name = 'module' ) #NEWLINE# mocked_module . Exploit = exploit_class #NEWLINE# self . interpreter . command_use ( module_path ) #NEWLINE# mocked_import_module . assert_called_once_with ( 'routersploit.modules.exploits.foo.bar' ) #NEWLINE# self . assertEqual ( self . interpreter . current_module , exploit_class ( ) )