How to use the pybuilder.errors.MissingPluginException function in pybuilder

To help you get started, we’ve selected a few pybuilder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pybuilder / pybuilder / src / unittest / python / pluginloader_tests.py View on Github external
def test_should_fail_with_vcs_and_no_module_name(self, install, load):
        install.side_effect = MissingPluginException("VCS BOOM")
        downloader = DownloadingPluginLoader(Mock())
        self.assertRaises(UnspecifiedPluginNameException, downloader.load_plugin, Mock(), "vcs:external_plugin URL")
github pybuilder / pybuilder / src / unittest / python / reactor_tests.py View on Github external
def test_should_raise_exception_when_importing_plugin_and_plugin_not_found(self):
        self.plugin_loader_mock.load_plugin.side_effect = MissingPluginException("not_found")

        self.assertRaises(
            MissingPluginException, self.reactor.import_plugin, "not_found")

        self.plugin_loader_mock.load_plugin.assert_called_with(ANY, "not_found", None, None)
github pybuilder / pybuilder / src / unittest / python / pluginloader_tests.py View on Github external
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")
github pybuilder / pybuilder / src / unittest / python / pluginloader_tests.py View on Github external
def test_should_return_module_returned_by_second_loader_when_first_delegatee_raises_exception(self):
        result = "result"
        self.first_delegatee.load_plugin.side_effect = MissingPluginException("spam")
        self.second_delegatee.load_plugin.return_value = result

        self.assertEquals(result, self.loader.load_plugin(self.project, "spam"))

        self.first_delegatee.load_plugin.assert_called_with(self.project, "spam", None, None)
        self.second_delegatee.load_plugin.assert_called_with(self.project, "spam", None, None)
github pybuilder / pybuilder / src / unittest / python / pluginloader_tests.py View on Github external
def test_should_not_update_pypi_plugin_with_exact_version_before_first_loading_attempt(self, install, load):
        project = Mock()
        downloader = DownloadingPluginLoader(Mock())
        plugin = Mock()
        load.side_effect = (MissingPluginException("no spam installed"), plugin)

        self.assertEquals(plugin, downloader.load_plugin(project, "pypi:spam", "===1.4"))

        install.assert_called_with(project, "pypi:spam", "===1.4", downloader.logger, None)
        self.assertEquals(install.call_count, 1)
github pybuilder / pybuilder / src / unittest / python / pluginloader_tests.py View on Github external
def test_should_raise_exception_when_all_delegatees_raise_exception(self):
        self.first_delegatee.load_plugin.side_effect = MissingPluginException("spam")
        self.second_delegatee.load_plugin.side_effect = MissingPluginException("spam")

        self.assertRaises(
            MissingPluginException, self.loader.load_plugin, self.project, "spam")

        self.first_delegatee.load_plugin.assert_called_with(self.project, "spam", None, None)
        self.second_delegatee.load_plugin.assert_called_with(self.project, "spam", None, None)
github pybuilder / pybuilder / src / unittest / python / pluginloader_tests.py View on Github external
def test_should_not_load_module_twice_after_downloading_when_vcs_download_fails(self, install, load):
        install.side_effect = MissingPluginException("VCS Install BOOM")
        load.side_effect = MissingPluginException("VCS Load Boom")
        downloader = DownloadingPluginLoader(Mock())
        self.assertRaises(MissingPluginException, downloader.load_plugin, Mock(), "vcs:external_plugin URL",
                          plugin_module_name="vcs_module_name")
        self.assertEquals(load.call_count, 1)
github pybuilder / pybuilder / src / main / python / pybuilder / pluginloader.py View on Github external
with tempfile.NamedTemporaryFile(mode="w+t") as log_file:
        result = pip_utils.pip_install(
            install_targets=pip_package,
            index_url=project.get_property("install_dependencies_index_url"),
            extra_index_url=project.get_property("install_dependencies_extra_index_url"),
            trusted_host=project.get_property("install_dependencies_trusted_host"),
            upgrade=upgrade,
            force_reinstall=force_reinstall,
            logger=logger,
            outfile_name=log_file,
            error_file_name=log_file,
            cwd=".")
        if result != 0:
            logger.error("The following pip error was encountered:\n" + "".join(read_file(log_file)))
            message = "Failed to install plugin from {0}".format(pip_package)
            raise MissingPluginException(name, message)
github pybuilder / pybuilder / src / main / python / pybuilder / pluginloader.py View on Github external
def _load_plugin(plugin_module_name, plugin_name):
    try:
        __import__(plugin_module_name)
        plugin_module = sys.modules[plugin_module_name]
        _check_plugin_version(plugin_module, plugin_name)
        return plugin_module

    except ImportError:
        raise MissingPluginException(plugin_name, format_exc())