本文整理汇总了Python中pants.option.option_value_container.OptionValueContainer.bar方法的典型用法代码示例。如果您正苦于以下问题:Python OptionValueContainer.bar方法的具体用法?Python OptionValueContainer.bar怎么用?Python OptionValueContainer.bar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.option.option_value_container.OptionValueContainer
的用法示例。
在下文中一共展示了OptionValueContainer.bar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_value_ranking
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_value_ranking(self):
o = OptionValueContainer()
o.add_forwardings({'foo': 'bar'})
o.bar = RankedValue(RankedValue.CONFIG, 11)
self.assertEqual(11, o.foo)
o.bar = RankedValue(RankedValue.HARDCODED, 22)
self.assertEqual(11, o.foo)
o.bar = RankedValue(RankedValue.ENVIRONMENT, 33)
self.assertEqual(33, o.foo)
o.bar = 44 # No explicit rank is assumed to be a FLAG.
self.assertEqual(44, o.foo)
示例2: test_is_flagged
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_is_flagged(self):
o = OptionValueContainer()
o.add_forwardings({'foo': 'bar'})
o.bar = RankedValue(RankedValue.NONE, 11)
self.assertFalse(o.is_flagged('foo'))
o.bar = RankedValue(RankedValue.CONFIG, 11)
self.assertFalse(o.is_flagged('foo'))
o.bar = RankedValue(RankedValue.ENVIRONMENT, 11)
self.assertFalse(o.is_flagged('foo'))
o.bar = RankedValue(RankedValue.FLAG, 11)
self.assertTrue(o.is_flagged('foo'))
示例3: test_forwarding
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_forwarding(self):
o = OptionValueContainer()
o.add_forwardings({'foo': 'bar'})
o.bar = 1
self.assertEqual(1, o.foo)
o.bar = 2
self.assertEqual(2, o.foo)
o.add_forwardings({'baz': 'qux'})
o.qux = 3
self.assertEqual(2, o.foo)
self.assertEqual(3, o.baz)
# Direct setting overrides forwarding.
o.foo = 4
self.assertEqual(4, o.foo)
示例4: test_deepcopy
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_deepcopy(self):
# deepcopy semantics can get hairy when overriding __setattr__/__getattr__, so we test them.
o = OptionValueContainer()
o.foo = 1
o.bar = {'a': 111}
p = copy.deepcopy(o)
o.bar['b'] = 222 # Add to original dict.
self.assertEqual(1, p.foo)
self.assertEqual({'a': 111}, p.bar) # Ensure dict was copied.
示例5: test_indexing
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_indexing(self):
o = OptionValueContainer()
o.add_forwardings({'foo': 'bar'})
o.bar = 1
self.assertEqual(1, o['foo'])
self.assertEqual(1, o['bar'])
with self.assertRaises(AttributeError):
o['baz']
示例6: test_copy
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_copy(self):
# copy semantics can get hairy when overriding __setattr__/__getattr__, so we test them.
o = OptionValueContainer()
o.add_forwardings({'foo': 'bar'})
o.add_forwardings({'baz': 'qux'})
o.bar = 1
o.qux = { 'a': 111 }
p = copy.copy(o)
o.baz['b'] = 222 # Add to original dict.
self.assertEqual(1, p.foo)
self.assertEqual({ 'a': 111, 'b': 222 }, p.baz) # Ensure dict was not copied.
示例7: test_indexing
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_indexing(self):
o = OptionValueContainer()
o.add_forwardings({'foo': 'bar'})
o.bar = 1
self.assertEqual(1, o['foo'])
self.assertEqual(1, o['bar'])
self.assertEqual(1, o.get('foo'))
self.assertEqual(1, o.get('foo', 2))
self.assertIsNone(o.get('unknown'))
self.assertEqual(2, o.get('unknown', 2))
with self.assertRaises(AttributeError):
o['baz']
示例8: test_deepcopy
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar [as 别名]
def test_deepcopy(self):
# copy semantics can get hairy when overriding __setattr__/__getattr__, so we test them.
o = OptionValueContainer()
o.foo = RankedValue(RankedValue.FLAG, 1)
o.bar = RankedValue(RankedValue.FLAG, {'a': 111})
p = copy.deepcopy(o)
# Verify that the result is in fact a copy.
self.assertEqual(1, p.foo) # Has original attribute.
o.baz = RankedValue(RankedValue.FLAG, 42)
self.assertFalse(hasattr(p, 'baz')) # Does not have attribute added after the copy.
# Verify that it's a deep copy by modifying a referent in o and reading it in p.
o.bar['b'] = 222
self.assertEqual({'a': 111}, p.bar)