當前位置: 首頁>>代碼示例>>Python>>正文


Python Reactor._prepare_tasks方法代碼示例

本文整理匯總了Python中pybuilder.reactor.Reactor._prepare_tasks方法的典型用法代碼示例。如果您正苦於以下問題:Python Reactor._prepare_tasks方法的具體用法?Python Reactor._prepare_tasks怎麽用?Python Reactor._prepare_tasks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pybuilder.reactor.Reactor的用法示例。


在下文中一共展示了Reactor._prepare_tasks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ReactorTest

# 需要導入模塊: from pybuilder.reactor import Reactor [as 別名]
# 或者: from pybuilder.reactor.Reactor import _prepare_tasks [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, [])
開發者ID:wenlien,項目名稱:pybuilder,代碼行數:104,代碼來源:reactor_tests.py


注:本文中的pybuilder.reactor.Reactor._prepare_tasks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。