本文整理匯總了Python中pybuilder.reactor.Reactor.get_plugins方法的典型用法代碼示例。如果您正苦於以下問題:Python Reactor.get_plugins方法的具體用法?Python Reactor.get_plugins怎麽用?Python Reactor.get_plugins使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pybuilder.reactor.Reactor
的用法示例。
在下文中一共展示了Reactor.get_plugins方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ReactorTest
# 需要導入模塊: from pybuilder.reactor import Reactor [as 別名]
# 或者: from pybuilder.reactor.Reactor import get_plugins [as 別名]
#.........這裏部分代碼省略.........
def test_should_return_directory_and_full_path_of_descriptor_when_verifying_project_directory(self):
when(os.path).abspath("spam").thenReturn("/spam")
when(os.path).exists("/spam").thenReturn(True)
when(os.path).isdir("/spam").thenReturn(True)
when(os.path).join("/spam", "eggs").thenReturn("/spam/eggs")
when(os.path).exists("/spam/eggs").thenReturn(True)
when(os.path).isfile("/spam/eggs").thenReturn(True)
self.assertEquals(
("/spam", "/spam/eggs"), self.reactor.verify_project_directory("spam", "eggs"))
verify(os.path).abspath("spam")
verify(os.path).exists("/spam")
verify(os.path).isdir("/spam")
verify(os.path).join("/spam", "eggs")
verify(os.path).exists("/spam/eggs")
verify(os.path).isfile("/spam/eggs")
def test_should_raise_exception_when_loading_project_module_and_import_raises_exception(self):
when(imp).load_source("build", "spam").thenRaise(ImportError("spam"))
self.assertRaises(
PyBuilderException, self.reactor.load_project_module, "spam")
verify(imp).load_source("build", "spam")
def test_should_return_module_when_loading_project_module_and_import_raises_exception(self):
module = mock()
when(imp).load_source("build", "spam").thenReturn(module)
self.assertEquals(module, self.reactor.load_project_module("spam"))
verify(imp).load_source("build", "spam")
def test_ensure_project_attributes_are_set_when_instantiating_project(self):
module = mock(version="version",
default_task="default_task",
summary="summary",
home_page="home_page",
description="description",
authors="authors",
license="license",
url="url")
self.reactor.project = mock()
self.reactor.project_module = module
self.reactor.apply_project_attributes()
self.assertEquals("version", self.reactor.project.version)
self.assertEquals("default_task", self.reactor.project.default_task)
self.assertEquals("summary", self.reactor.project.summary)
self.assertEquals("home_page", self.reactor.project.home_page)
self.assertEquals("description", self.reactor.project.description)
self.assertEquals("authors", self.reactor.project.authors)
self.assertEquals("license", self.reactor.project.license)
self.assertEquals("url", self.reactor.project.url)
def test_ensure_project_name_is_set_from_attribute_when_instantiating_project(self):
module = mock(name="name")
self.reactor.project = mock()
self.reactor.project_module = module
self.reactor.apply_project_attributes()
self.assertEquals("name", self.reactor.project.name)
def test_should_import_plugin_only_once(self):
plugin_module = mock()
when(self.plugin_loader_mock).load_plugin(
any(), "spam", any()).thenReturn(plugin_module)
self.reactor.require_plugin("spam")
self.reactor.require_plugin("spam")
self.assertEquals(["spam"], self.reactor.get_plugins())
verify(self.plugin_loader_mock).load_plugin(any(), "spam", None, None)
def test_ensure_project_properties_are_logged_when_calling_log_project_properties(self):
project = Project("spam")
project.set_property("spam", "spam")
project.set_property("eggs", "eggs")
self.reactor.project = project
self.reactor.log_project_properties()
verify(self.logger).debug(
"Project properties: %s", contains("basedir : spam"))
verify(self.logger).debug(
"Project properties: %s", contains("eggs : eggs"))
verify(self.logger).debug(
"Project properties: %s", contains("spam : spam"))
def test_should_raise_exception_when_project_is_not_valid(self):
self.reactor.project = mock(properties={})
when(self.reactor.project).validate().thenReturn(["spam"])
self.assertRaises(ProjectValidationFailedException, self.reactor.build)
示例2: ReactorTest
# 需要導入模塊: from pybuilder.reactor import Reactor [as 別名]
# 或者: from pybuilder.reactor.Reactor import get_plugins [as 別名]
#.........這裏部分代碼省略.........
def test_should_return_module_when_loading_project_module_and_import_raises_exception(self, imp_load_source):
self.assertTrue(imp_load_source.return_value is self.reactor.load_project_module("spam"))
imp_load_source.assert_called_with("build", "spam")
def test_ensure_project_attributes_are_set_when_instantiating_project(self):
module = ModuleType("mock_module")
module.version = "version"
module.default_task = "default_task"
module.summary = "summary"
module.home_page = "home_page"
module.description = "description"
module.authors = "authors"
module.license = "license"
module.url = "url"
self.reactor.project = Mock()
self.reactor.project_module = module
self.reactor.apply_project_attributes()
self.assertEquals("version", self.reactor.project.version)
self.assertEquals("default_task", self.reactor.project.default_task)
self.assertEquals("summary", self.reactor.project.summary)
self.assertEquals("home_page", self.reactor.project.home_page)
self.assertEquals("description", self.reactor.project.description)
self.assertEquals("authors", self.reactor.project.authors)
self.assertEquals("license", self.reactor.project.license)
self.assertEquals("url", self.reactor.project.url)
def test_ensure_project_name_is_set_from_attribute_when_instantiating_project(self):
module = ModuleType("mock_module")
module.name = "mock_module"
self.reactor.project = Mock()
self.reactor.project_module = module
self.reactor.apply_project_attributes()
self.assertEquals("mock_module", self.reactor.project.name)
def test_should_import_plugin_only_once(self):
plugin_module = ModuleType("mock_module")
self.plugin_loader_mock.load_plugin.return_value = plugin_module
self.reactor.require_plugin("spam")
self.reactor.require_plugin("spam")
self.assertEquals(["spam"], self.reactor.get_plugins())
self.plugin_loader_mock.load_plugin.assert_called_with(ANY, "spam", None, None)
def test_ensure_project_properties_are_logged_when_calling_log_project_properties(self):
project = Project("spam")
project.set_property("spam", "spam")
project.set_property("eggs", "eggs")
self.reactor.project = project
self.reactor.log_project_properties()
call_args = self.logger.debug.call_args
self.assertEquals(call_args[0][0], "Project properties: %s")
self.assertTrue("basedir : spam" in call_args[0][1])
self.assertTrue("eggs : eggs" in call_args[0][1])
self.assertTrue("spam : spam" in call_args[0][1])
def test_should_raise_exception_when_project_is_not_valid(self):
self.reactor.project = Mock(properties={})
self.reactor.project.validate.return_value = ["spam"]
self.assertRaises(ProjectValidationFailedException, self.reactor.build)
def test_prepare_tasks(self):
self.reactor.project = Project("spam")
self.reactor.project.default_task = ["a", "b"]
self.assertEquals(self.reactor._prepare_tasks(["c"]), ["c"])
self.assertEquals(self.reactor._prepare_tasks(["+c"]), ["a", "b", "c"])
self.assertEquals(self.reactor._prepare_tasks(["+c", '^c']), ["a", "b"])
self.assertEquals(self.reactor._prepare_tasks(["^b"]), ["a"])
self.assertEquals(self.reactor._prepare_tasks(["^a"]), ["b"])
self.assertEquals(self.reactor._prepare_tasks(["^d"]), ["a", "b"])
self.assertEquals(self.reactor._prepare_tasks(["+c", "d"]), ["d", "c"])
self.assertEquals(self.reactor._prepare_tasks(["+c", "d", "^b"]), ["d", "c"])
self.assertEquals(self.reactor._prepare_tasks(["+c", "+", "^"]), ["+", "^", "c"])
self.assertEquals(self.reactor._prepare_tasks([]), ["a", "b"])
self.reactor.project.default_task = []
self.assertEquals(self.reactor._prepare_tasks(["c"]), ["c"])
self.assertEquals(self.reactor._prepare_tasks(["+c"]), ["c"])
self.assertEquals(self.reactor._prepare_tasks(["+c", "^d"]), ["c"])
self.assertEquals(self.reactor._prepare_tasks(["+c", "d", "^d"]), ["c"])
self.assertEquals(self.reactor._prepare_tasks(["^c", "c"]), [])
self.assertEquals(self.reactor._prepare_tasks(["+c", "^c"]), [])
self.assertEquals(self.reactor._prepare_tasks(["+c", "d"]), ["d", "c"])
self.assertEquals(self.reactor._prepare_tasks(["+c", "+"]), ["+", "c"])
self.assertRaises(PyBuilderException, self.reactor._prepare_tasks, [])