class BuiltinPluginLoaderTest(unittest.TestCase): def setUp(self): self.project = mock() self.loader = BuiltinPluginLoader(mock()) def tearDown(self): unstub() def test_should_raise_exception_when_requiring_plugin_and_plugin_is_not_found(self): when(builtin_module).__import__( "pybuilder.plugins.spam_plugin").thenRaise(ImportError()) self.assertRaises( MissingPluginException, self.loader.load_plugin, self.project, "spam") verify(builtin_module).__import__("pybuilder.plugins.spam_plugin") def test_should_import_plugin_when_requiring_plugin_and_plugin_is_found_as_builtin(self): old_module = sys.modules.get("pybuilder.plugins.spam_plugin") try: plugin_module = mock() sys.modules["pybuilder.plugins.spam_plugin"] = plugin_module when(builtin_module).__import__( "pybuilder.plugins.spam_plugin").thenReturn(plugin_module) self.loader.load_plugin(self.project, "spam") verify(builtin_module).__import__("pybuilder.plugins.spam_plugin") finally: del sys.modules["pybuilder.plugins.spam_plugin"] if old_module: sys.modules["pybuilder.plugins.spam_plugin"] = old_module
class BuiltinPluginLoaderTest(unittest.TestCase): def setUp(self): self.project = mock() self.loader = BuiltinPluginLoader(mock()) def tearDown(self): unstub() def test_should_raise_exception_when_requiring_plugin_and_plugin_is_not_found( self): when(builtin_module).__import__( "pybuilder.plugins.spam_plugin").thenRaise(ImportError()) self.assertRaises(MissingPluginException, self.loader.load_plugin, self.project, "spam") verify(builtin_module).__import__("pybuilder.plugins.spam_plugin") def test_should_import_plugin_when_requiring_plugin_and_plugin_is_found_as_builtin( self): old_module = sys.modules.get("pybuilder.plugins.spam_plugin") try: plugin_module = mock() plugin_module.pyb_version = None sys.modules["pybuilder.plugins.spam_plugin"] = plugin_module when(builtin_module).__import__( "pybuilder.plugins.spam_plugin").thenReturn(plugin_module) self.loader.load_plugin(self.project, "spam") verify(builtin_module).__import__("pybuilder.plugins.spam_plugin") finally: del sys.modules["pybuilder.plugins.spam_plugin"] if old_module: sys.modules["pybuilder.plugins.spam_plugin"] = old_module
class BuiltinPluginLoaderTest(unittest.TestCase): def setUp(self): self.project = Mock() self.loader = BuiltinPluginLoader(Mock()) @patch("pybuilder.pluginloader._load_plugin") def test_should_raise_exception_when_requiring_plugin_and_plugin_is_not_found( self, load): load.side_effect = MissingPluginException( "pybuilder.plugins.spam_plugin") self.assertRaises(MissingPluginException, self.loader.load_plugin, self.project, PluginDef("spam")) load.assert_has_calls([ call("pybuilder.plugins.spam_plugin", "spam"), call("spam", "spam") ]) @patch("pybuilder.pluginloader._load_plugin") def test_should_import_plugin_when_requiring_plugin_and_plugin_is_found_as_builtin( self, load): load.return_value = Mock() plugin_module = self.loader.load_plugin(self.project, PluginDef("spam")) load.assert_called_with("pybuilder.plugins.spam_plugin", "spam") self.assertEqual(load.return_value, plugin_module)
def __init__(self, logger, execution_manager, plugin_loader=None): self.logger = logger self.execution_manager = execution_manager if not plugin_loader: self.plugin_loader = DispatchingPluginLoader( self.logger, BuiltinPluginLoader(self.logger), DownloadingPluginLoader(self.logger)) else: self.plugin_loader = plugin_loader self._plugins = [] self._pending_plugin_installs = [] self._plugins_imported = set() self._deferred_plugins = ModuleTraversalTree() self._deferred_import = False self.project = None self.project_module = None self._tools = [] python_env_registry = self._python_env_registry = PythonEnvRegistry( self) system_pyenv = PythonEnv(sys.exec_prefix, self).populate() python_env_registry["system"] = system_pyenv self._sys_path_original = list(sys.path)
def __init__(self, logger, execution_manager, plugin_loader=None): self.logger = logger self.execution_manager = execution_manager if not plugin_loader: self.plugin_loader = DispatchingPluginLoader(self.logger, BuiltinPluginLoader(self.logger), DownloadingPluginLoader(self.logger)) else: self.plugin_loader = plugin_loader self._plugins = [] self.project = None
def __init__(self, logger, execution_manager, plugin_loader=None): self.logger = logger self.execution_manager = execution_manager if not plugin_loader: builtin_plugin_loader = BuiltinPluginLoader(self.logger) installed_thirdparty_plugin_loader = ThirdPartyPluginLoader( self.logger) downloading_thirdparty_plugin_loader = DownloadingPluginLoader( self.logger) self.plugin_loader = DispatchingPluginLoader( self.logger, builtin_plugin_loader, installed_thirdparty_plugin_loader, downloading_thirdparty_plugin_loader) else: self.plugin_loader = plugin_loader self._plugins = [] self.project = None
class BuiltinPluginLoaderTest(unittest.TestCase): def setUp(self): self.project = Mock() self.loader = BuiltinPluginLoader(Mock()) @patch("pybuilder.pluginloader._load_plugin") def test_should_raise_exception_when_requiring_plugin_and_plugin_is_not_found(self, load): load.side_effect = MissingPluginException("pybuilder.plugins.spam_plugin") self.assertRaises(MissingPluginException, self.loader.load_plugin, self.project, "spam") load.assert_called_with("pybuilder.plugins.spam_plugin", "spam") @patch("pybuilder.pluginloader._load_plugin") def test_should_import_plugin_when_requiring_plugin_and_plugin_is_found_as_builtin(self, load): load.return_value = Mock() plugin_module = self.loader.load_plugin(self.project, "spam") load.assert_called_with("pybuilder.plugins.spam_plugin", "spam") self.assertEquals(load.return_value, plugin_module)
def setUp(self): self.project = mock() self.loader = BuiltinPluginLoader(mock())
def setUp(self): super(BuiltinPluginLoaderTest, self).setUp() self.project = mock() self.loader = BuiltinPluginLoader(mock())