本文整理汇总了Python中pybuilder.reactor.Reactor类的典型用法代码示例。如果您正苦于以下问题:Python Reactor类的具体用法?Python Reactor怎么用?Python Reactor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reactor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.old_reactor = Reactor.current_instance()
self.plugin_loader_mock = Mock(PluginLoader)
self.logger = Mock()
self.execution_manager = Mock(ExecutionManager)
self.reactor = Reactor(
self.logger, self.execution_manager, self.plugin_loader_mock)
开发者ID:wenlien,项目名称:pybuilder,代码行数:7,代码来源:reactor_tests.py
示例2: get_all_dependencies_for_task
def get_all_dependencies_for_task(task):
"""
Returns a list containing all tasks required by the given
task function (but not the given task itself)
"""
from pybuilder.reactor import Reactor
task_name = task.__name__
execution_manager = Reactor.current_instance().execution_manager
task_and_all_dependencies = execution_manager.collect_all_transitive_tasks([task_name])
return [dependency for dependency in task_and_all_dependencies if dependency.name != task_name]
开发者ID:010110101001,项目名称:pybuilder,代码行数:10,代码来源:utils.py
示例3: setUp
def setUp(self):
self.plugin_loader_mock = mock(PluginLoader)
self.logger = mock()
self.execution_manager = mock(ExecutionManager)
self.reactor = Reactor(
self.logger, self.execution_manager, self.plugin_loader_mock)
开发者ID:Ferreiros-lab,项目名称:pybuilder,代码行数:6,代码来源:reactor_tests.py
示例4: ReactorTest
class ReactorTest(unittest.TestCase):
def setUp(self):
self.plugin_loader_mock = mock(PluginLoader)
self.logger = mock()
self.execution_manager = mock(ExecutionManager)
self.reactor = Reactor(
self.logger, self.execution_manager, self.plugin_loader_mock)
def tearDown(self):
unstub()
def test_should_return_tasks_from_execution_manager_when_calling_get_tasks(self):
self.execution_manager.tasks = ["spam"]
self.assertEquals(["spam"], self.reactor.get_tasks())
def test_should_raise_exception_when_importing_plugin_and_plugin_not_found(self):
when(self.plugin_loader_mock).load_plugin(
any(), "not_found", any(), any()).thenRaise(MissingPluginException("not_found"))
self.assertRaises(
MissingPluginException, self.reactor.import_plugin, "not_found")
verify(self.plugin_loader_mock).load_plugin(any(), "not_found", None, None)
def test_should_collect_single_task(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
module = mock()
module.task = task
self.reactor.collect_tasks_and_actions_and_initializers(module)
verify(self.execution_manager).register_task(TaskNameMatcher("task"))
def test_should_collect_single_task_with_overridden_name(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
setattr(task, NAME_ATTRIBUTE, "overridden_name")
module = mock()
module.task = task
self.reactor.collect_tasks_and_actions_and_initializers(module)
verify(self.execution_manager).register_task(
TaskNameMatcher("overridden_name"))
def test_should_collect_multiple_tasks(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
def task2():
pass
setattr(task2, TASK_ATTRIBUTE, True)
module = mock()
module.task = task
module.task2 = task2
self.reactor.collect_tasks_and_actions_and_initializers(module)
verify(self.execution_manager, times(2)).register_task(any(Task))
def test_task_dependencies(self):
import pybuilder.reactor
when(pybuilder.reactor).Task().thenReturn(mock())
@task
def task1():
pass
@task
@depends(task1)
def task2():
pass
@task
def task3():
pass
@task
@depends(optional(task3))
@dependents("task6")
def task4():
pass
@task
@dependents("task6", optional(task3))
def task5():
pass
#.........这里部分代码省略.........
开发者ID:Ferreiros-lab,项目名称:pybuilder,代码行数:101,代码来源:reactor_tests.py
示例5: use_plugin
def use_plugin(name, version=None, plugin_module_name=None):
from pybuilder.reactor import Reactor
reactor = Reactor.current_instance()
if reactor is not None:
reactor.require_plugin(name, version, plugin_module_name)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:5,代码来源:core.py
示例6: prepare_reactor
def prepare_reactor(self):
logger = StdOutLogger(threshold=Logger.DEBUG)
execution_manager = ExecutionManager(logger)
reactor = Reactor(logger, execution_manager)
reactor.prepare_build(project_directory=self.tmp_directory)
return reactor
开发者ID:runt18,项目名称:pybuilder,代码行数:6,代码来源:integrationtest_support.py
示例7: use_plugin
def use_plugin(name):
from pybuilder.reactor import Reactor
reactor = Reactor.current_instance()
if reactor is not None:
reactor.require_plugin(name)
开发者ID:jewishjeff,项目名称:pybuilder,代码行数:6,代码来源:core.py
示例8: tearDown
def tearDown(self):
Reactor._set_current_instance(self.old_reactor)
开发者ID:wenlien,项目名称:pybuilder,代码行数:2,代码来源:reactor_tests.py
示例9: ReactorTest
class ReactorTest(unittest.TestCase):
def setUp(self):
self.old_reactor = Reactor.current_instance()
self.plugin_loader_mock = Mock(PluginLoader)
self.logger = Mock()
self.execution_manager = Mock(ExecutionManager)
self.reactor = Reactor(
self.logger, self.execution_manager, self.plugin_loader_mock)
def tearDown(self):
Reactor._set_current_instance(self.old_reactor)
def test_should_return_tasks_from_execution_manager_when_calling_get_tasks(self):
self.execution_manager.tasks = ["spam"]
self.assertEquals(["spam"], self.reactor.get_tasks())
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)
def test_should_collect_single_task(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
module = ModuleType("mock_module")
module.task = task
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(len(self.execution_manager.register_task.call_args_list), 1)
self.assertTrue(isinstance(self.execution_manager.register_task.call_args[0][0], Task) and len(
self.execution_manager.register_task.call_args[0]) == 1)
self.assertEquals(self.execution_manager.register_task.call_args[0][0].name, "task")
def test_should_collect_single_task_with_overridden_name(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
setattr(task, NAME_ATTRIBUTE, "overridden_name")
module = ModuleType("mock_module")
module.task = task
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(len(self.execution_manager.register_task.call_args_list), 1)
self.assertTrue(isinstance(self.execution_manager.register_task.call_args[0][0], Task) and len(
self.execution_manager.register_task.call_args[0]) == 1)
self.assertEquals(self.execution_manager.register_task.call_args[0][0].name, "overridden_name")
def test_should_collect_multiple_tasks(self):
def task():
pass
setattr(task, TASK_ATTRIBUTE, True)
def task2():
pass
setattr(task2, TASK_ATTRIBUTE, True)
module = ModuleType("mock_module")
module.task = task
module.task2 = task2
self.reactor.collect_tasks_and_actions_and_initializers(module)
self.assertEquals(len(self.execution_manager.register_task.call_args_list), 2)
for call_args in self.execution_manager.register_task.call_args_list:
self.assertTrue(isinstance(call_args[0][0], Task) and len(call_args[0]) == 1)
def test_task_dependencies(self):
import pybuilder.reactor
with patch("pybuilder.reactor.Task"):
@task
def task1():
pass
@task
@depends(task1)
def task2():
pass
@task
def task3():
pass
@task
@depends(optional(task3))
@dependents("task6")
def task4():
pass
#.........这里部分代码省略.........
开发者ID:wenlien,项目名称:pybuilder,代码行数:101,代码来源:reactor_tests.py
注:本文中的pybuilder.reactor.Reactor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论