本文整理汇总了Python中binding.Context.bind_generator_next方法的典型用法代码示例。如果您正苦于以下问题:Python Context.bind_generator_next方法的具体用法?Python Context.bind_generator_next怎么用?Python Context.bind_generator_next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类binding.Context
的用法示例。
在下文中一共展示了Context.bind_generator_next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mixing_binds
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import bind_generator_next [as 别名]
def test_mixing_binds(self):
""" Ensure that variables are set correctly when mixing explicit declaration and variables """
context = Context()
context.add_generator('gen', count_gen())
context.bind_variable('foo', '100')
self.assertEqual(1, context.mod_count)
context.bind_generator_next('foo', 'gen')
self.assertEqual(1, context.get_value('foo'))
self.assertEqual(2, context.mod_count)
示例2: test_generator_bind
# 需要导入模块: from binding import Context [as 别名]
# 或者: from binding.Context import bind_generator_next [as 别名]
def test_generator_bind(self):
""" Test generator setting to variables """
context = Context()
self.assertEqual(0, len(context.get_generators()))
my_gen = count_gen()
context.add_generator('gen', my_gen)
context.bind_generator_next('foo', 'gen')
self.assertEqual(1, context.mod_count)
self.assertEqual(1, context.get_value('foo'))
self.assertTrue(2, context.get_generator('gen').next())
self.assertTrue(3, my_gen.next())