本文整理汇总了Python中libgiza.app.BuildApp.add方法的典型用法代码示例。如果您正苦于以下问题:Python BuildApp.add方法的具体用法?Python BuildApp.add怎么用?Python BuildApp.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libgiza.app.BuildApp
的用法示例。
在下文中一共展示了BuildApp.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBuildAppStandardConfig
# 需要导入模块: from libgiza.app import BuildApp [as 别名]
# 或者: from libgiza.app.BuildApp import add [as 别名]
class TestBuildAppStandardConfig(CommonAppSuite, TestCase):
def setUp(self):
self.c = Configuration()
self.c.runstate = RuntimeStateConfig()
self.app = BuildApp(self.c)
self.app.default_pool = random.choice(['serial', 'thread'])
self.app.pool_size = 2
def test_conf_object_consistent_in_task(self):
self.assertEqual(self.app.queue, [])
t = self.app.add('task')
self.assertIs(self.c, t.conf)
self.assertIs(self.c, self.app.queue[0].conf)
def test_conf_object_consistent_in_app(self):
self.assertEqual(self.app.queue, [])
self.app.add('app')
self.assertIs(self.c, self.app.conf)
self.assertIs(self.c, self.app.queue[0].conf)
def test_conf_object_consistent_in_new_task(self):
self.assertEqual(self.app.queue, [])
t = Task()
self.assertIsNone(t.conf)
self.app.add(t)
self.assertIsNotNone(t.conf)
self.assertIs(self.c, self.app.queue[0].conf)
self.assertIs(self.c, t.conf)
def test_force_options(self):
self.assertEquals(self.c.runstate.force, self.app.force)
self.assertFalse(self.c.runstate.force)
self.assertFalse(self.app.force)
self.app._force = None
self.assertFalse(self.app.force)
def test_default_pool_size(self):
self.assertIsNotNone(self.c)
self.assertIsNotNone(self.app.conf)
self.app._pool_size = None
self.assertEquals(self.c.runstate.pool_size, self.app.pool_size)
def tearDown(self):
self.app.close_pool()
示例2: test_single_runner_app
# 需要导入模块: from libgiza.app import BuildApp [as 别名]
# 或者: from libgiza.app.BuildApp import add [as 别名]
def test_single_runner_app(self):
self.assertEqual(self.app.queue, [])
self.assertEqual(self.app.results, [])
app = BuildApp()
app.pool_size = 2
t = app.add('task')
t.job = sum
t.args = [[1, 2], 0]
t.description = 'test task'
self.app.add(app)
self.app.run()
self.assertEqual(self.app.results[0], 3)
示例3: test_single_runner_app_with_many_subtasks
# 需要导入模块: from libgiza.app import BuildApp [as 别名]
# 或者: from libgiza.app.BuildApp import add [as 别名]
def test_single_runner_app_with_many_subtasks(self):
self.assertEqual(self.app.queue, [])
self.assertEqual(self.app.results, [])
app = BuildApp()
app.pool_size = 2
for _ in range(10):
t = app.add('task')
t.job = sum
t.description = 'test task'
t.args = [[1, 2], 0]
self.app.add(app)
self.app.run()
self.assertEqual(len(self.app.results), 10)
self.assertEqual(self.app.results[0], 3)
self.assertEqual(sum(self.app.results), 30)