本文整理汇总了Python中pants.option.option_value_container.OptionValueContainer.add_forwardings方法的典型用法代码示例。如果您正苦于以下问题:Python OptionValueContainer.add_forwardings方法的具体用法?Python OptionValueContainer.add_forwardings怎么用?Python OptionValueContainer.add_forwardings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.option.option_value_container.OptionValueContainer
的用法示例。
在下文中一共展示了OptionValueContainer.add_forwardings方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_indexing
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [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']
示例2: test_deepcopy
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [as 别名]
def test_deepcopy(self):
# deepcopy 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.deepcopy(o)
o.baz['b'] = 222 # Add to original dict.
self.assertEqual(1, p.foo)
self.assertEqual({'a': 111}, p.baz) # Ensure dict was copied.
示例3: test_value_ranking
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [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)
示例4: test_indexing
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [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']
示例5: test_is_flagged
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [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'))
示例6: test_forwarding
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [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)
示例7: test_iterator
# 需要导入模块: from pants.option.option_value_container import OptionValueContainer [as 别名]
# 或者: from pants.option.option_value_container.OptionValueContainer import add_forwardings [as 别名]
def test_iterator(self):
o = OptionValueContainer()
o.add_forwardings({'a': '_a'})
o.add_forwardings({'b': '_b'})
o.add_forwardings({'b_prime': '_b'}) # Should be elided in favor of b.
o.add_forwardings({'c': '_c'})
names = list(iter(o))
self.assertListEqual(['a', 'b', 'c'], names)