本文整理汇总了Python中aql.options.Options.override方法的典型用法代码示例。如果您正苦于以下问题:Python Options.override方法的具体用法?Python Options.override怎么用?Python Options.override使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aql.options.Options
的用法示例。
在下文中一共展示了Options.override方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_options_merge
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import override [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 )
示例2: test_options_tool_keys
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import override [as 别名]
def test_options_tool_keys(self):
options = Options()
options.cc_name = StrOptionType(is_tool_key=True)
options.cc_ver = StrOptionType(is_tool_key=True)
options.ccflags = ListOptionType(separators=None)
options.cc = PathOptionType()
options.cc = 'gcc'
options.ccflags = '-c'
child = options.override()
child.cc = 'g++'
child.ccflags = '-O3'
self.assertFalse(child.has_changed_key_options())
child.cc_name = 'icc'
self.assertFalse(child.has_changed_key_options())
options.cc_name = 'gcc'
self.assertTrue(child.has_changed_key_options())
child.cc_name = 'gcc'
self.assertFalse(child.has_changed_key_options())
child.cc_ver = '4.9'
self.assertFalse(child.has_changed_key_options())
options.cc_ver = '4.8'
self.assertTrue(child.has_changed_key_options())
示例3: test_options
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import override [as 别名]
def test_options(self):
options = Options()
opt_type1 = RangeOptionType(min_value=0, max_value=5)
options.warn_level = opt_type1
options.warning_level = options.warn_level
self.assertEqual(options.warn_level, options.warning_level)
options.warning_level = 1
self.assertEqual(options.warn_level, options.warning_level)
options.warning_level += 1
self.assertEqual(options.warn_level, 2)
options.warning_level -= 2
self.assertEqual(options.warn_level, 0)
opt_type2 = BoolOptionType()
options.debug_on = opt_type2
options.debug_on = True
self.assertEqual(options.debug_on, 'true')
over_opts = options.override()
self.assertEqual(over_opts.debug_on, 'true')
options.debug_on = False
self.assertEqual(over_opts.debug_on, 'false')
options.debug_on = True
self.assertEqual(over_opts.debug_on, 'true')
over_opts.debug_on = False
self.assertEqual(options.debug_on, 'true')
self.assertEqual(over_opts.debug_on, 'false')
self.assertEqual(over_opts.warn_level, 0)
options.warning_level = 3
self.assertEqual(over_opts.warn_level, 3)
self.assertEqual(over_opts.warning_level, 3)
over_opts.warn_level.set(1)
self.assertEqual(options.warning_level, 3)
self.assertEqual(options.warn_level, 3)
self.assertEqual(over_opts.warning_level, 1)
self.assertEqual(over_opts.warn_level, 1)
over_opts = over_opts.copy()
options.warning_level = 2
self.assertEqual(options.warn_level, 2)
self.assertEqual(over_opts.warn_level, 1)
self.assertEqual(over_opts.warning_level, 1)
over_opts.warn_level = 4
self.assertEqual(over_opts.warn_level, 4)
self.assertEqual(over_opts.warning_level, 4)
示例4: test_options_parent_refs
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import override [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)
示例5: test_options_join_2
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import override [as 别名]
def test_options_join_2(self):
options = Options()
options.arg1 = 1
options.arg2 = 2
options2 = options.override()
options2.arg3 = 3
options2.arg4 = 4
options3 = options2.override()
options3.arg5 = 5
options3.arg7 = 7
options3.join()
self.assertIs(options.arg1.option_value, options2.arg1.option_value)
self.assertIs(options.arg2.option_value, options2.arg2.option_value)
self.assertEqual(options2.arg5, 5)
self.assertEqual(options2.arg7, 7)
options2.arg1 = 11
self.assertIsNot(options.arg1.option_value, options2.arg1.option_value)
self.assertIs(options.arg2.option_value, options2.arg2.option_value)
示例6: test_options_clear
# 需要导入模块: from aql.options import Options [as 别名]
# 或者: from aql.options.Options import override [as 别名]
def test_options_clear(self):
options = Options()
options.override()
child = options.override()
child.clear()