本文整理汇总了Python中aql.options.Options.opt2方法的典型用法代码示例。如果您正苦于以下问题:Python Options.opt2方法的具体用法?Python Options.opt2怎么用?Python Options.opt2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aql.options.Options
的用法示例。
在下文中一共展示了Options.opt2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_options_errors
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import opt2 [as 别名]
def test_options_errors(self):
options = Options()
options2 = Options()
options.opt = RangeOptionType(min_value=1, max_value=100)
options.warn_level = RangeOptionType(min_value=0, max_value=5)
options.opt = RangeOptionType(min_value=1, max_value=100)
options2.opt2 = options.opt
self.assertEqual(options.opt.get(), options2.opt2.get())
options.opt = 50
self.assertEqual(options.opt.get(), options2.opt2.get())
options.opt = 20
self.assertEqual(options.opt.get(), options2.opt2.get())
options2.opt2 = 48
self.assertNotEqual(options.opt.get(), options2.opt2.get())
self.assertEqual(options.opt.get(), 20)
self.assertEqual(options2.opt2.get(), 48)
self.assertRaises(AttributeError, options.__getattr__, 'debug_on')
options.opt = options.warn_level
options.warn_level = 2
self.assertEqual(options.opt, options.warn_level)
self.assertEqual(options.opt, 2)
self.assertIn('opt', options)
self.assertNotIn('debug_on', options)
self.assertRaises(ErrorOptionsNoIteration, iter, options)
示例2: test_options_merge
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import opt2 [as 别名]
def test_options_merge(self):
options = Options()
options.opt1 = RangeOptionType( min_value = 1, max_value = 100 )
options.opt2 = RangeOptionType( min_value = 0, max_value = 5 )
options.opt3 = RangeOptionType( min_value = -10, max_value = 10 )
options.option1 = options.opt1
options.option3 = options.opt3
options.opt1 = 50
options.opt2 = 3
options.opt3 = 0
options2 = Options()
options2.opt21 = RangeOptionType( min_value = 1, max_value = 100 )
options2.opt22 = RangeOptionType( min_value = 0, max_value = 5 )
options2.opt23 = RangeOptionType( min_value = -10, max_value = 10 )
options2.option22 = options2.opt22
options2.option23 = options2.opt23
options.merge( options2 )
self.assertEqual( options.opt1, 50 )
self.assertEqual( options.opt2, 3 )
self.assertEqual( options.opt3, 0 )
self.assertIs( options.option1.option_value, options.opt1.option_value )
self.assertIs( options.option3.option_value, options.opt3.option_value )
self.assertEqual( options.opt21, options2.opt21 )
self.assertEqual( options.opt23, options2.opt23 )
self.assertEqual( options.opt22, options2.opt22 )
self.assertIs( options.option22.option_value, options.opt22.option_value )
self.assertIs( options.option23.option_value, options.opt23.option_value )
child_options2 = options2.override()
child_options2.option21 = child_options2.opt21
self.assertIs( child_options2.option21.option_value, child_options2.opt21.option_value )
child_options2.opt22 = 3
child_options2.opt23 = 7
child_options2.join()
self.assertIs( options2.option21.option_value, options2.opt21.option_value )
self.assertEqual( options2.opt22, 3 )
self.assertEqual( options2.opt23, 7 )
self.assertFalse( child_options2 )
child_options2 = options2.override()
options2.option_21 = options2.opt21
child_options2.opt22 = 4
child_options2.opt23 = 8
child_options2.unjoin()
self.assertIs( child_options2.option21.option_value, child_options2.option_21.option_value )
self.assertIs( child_options2.option21.option_value, child_options2.opt21.option_value )
self.assertIsNot( child_options2.opt21.option_value, options2.opt21.option_value )
示例3: test_options_parent_refs
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import opt2 [as 别名]
def test_options_parent_refs(self):
options = Options()
options.opt1 = RangeOptionType(min_value=1, max_value=100)
options.opt2 = RangeOptionType(min_value=0, max_value=5)
options.opt1 = 10
options.opt2 = options.opt1
self.assertEqual(options.opt1, 10)
self.assertEqual(options.opt2, 5)
options2 = options.override()
options2.opt1 = 3
self.assertEqual(options.opt1, 10)
self.assertEqual(options2.opt1, 3)
self.assertEqual(options2.opt2, 3)
options2.opt2 = options.opt1
self.assertEqual(options2.opt2, 3)
options2.opt1 = 1
self.assertEqual(options2.opt2, 1)
示例4: test_options_refs
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import opt2 [as 别名]
def test_options_refs(self):
options = Options()
options.opt = RangeOptionType(min_value=1, max_value=100)
options.warn_level = RangeOptionType(min_value=0, max_value=5)
options.warn_level = op_iadd(options.opt)
self.assertEqual(options.warn_level, 1)
options.If().warn_level.eq(options.opt).warn_level += 1
self.assertEqual(options.warn_level, 2)
options.opt = 2
self.assertEqual(options.warn_level, 3)
options2 = Options()
options2.opt1 = RangeOptionType(min_value=1, max_value=100)
options2.opt2 = RangeOptionType(min_value=1, max_value=100)
options.warn_level = options2.opt1
self.assertEqual(options.warn_level.get(), options2.opt1.get())
options2.opt1 = 4
self.assertEqual(options.warn_level.get(), options2.opt1.get())
self.assertRaises(
ErrorOptionsCyclicallyDependent, options2.opt2.set, options.opt)
options.warn_level.set(options.opt)
self.assertEqual(options.warn_level, 2)
options.test = 1
self.assertEqual(options.test.get(), 1)
options.opt += options.opt
self.assertEqual(options.opt, 4)