本文整理匯總了Python中pants.option.option_value_container.OptionValueContainer.foo方法的典型用法代碼示例。如果您正苦於以下問題:Python OptionValueContainer.foo方法的具體用法?Python OptionValueContainer.foo怎麽用?Python OptionValueContainer.foo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pants.option.option_value_container.OptionValueContainer
的用法示例。
在下文中一共展示了OptionValueContainer.foo方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_is_flagged
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [as 別名]
def test_is_flagged(self):
o = OptionValueContainer()
o.foo = RankedValue(RankedValue.NONE, 11)
self.assertFalse(o.is_flagged('foo'))
o.foo = RankedValue(RankedValue.CONFIG, 11)
self.assertFalse(o.is_flagged('foo'))
o.foo = RankedValue(RankedValue.ENVIRONMENT, 11)
self.assertFalse(o.is_flagged('foo'))
o.foo = RankedValue(RankedValue.FLAG, 11)
self.assertTrue(o.is_flagged('foo'))
示例2: test_value_ranking
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [as 別名]
def test_value_ranking(self):
o = OptionValueContainer()
o.foo = RankedValue(RankedValue.CONFIG, 11)
self.assertEqual(11, o.foo)
self.assertEqual(RankedValue.CONFIG, o.get_rank('foo'))
o.foo = RankedValue(RankedValue.HARDCODED, 22)
self.assertEqual(11, o.foo)
self.assertEqual(RankedValue.CONFIG, o.get_rank('foo'))
o.foo = RankedValue(RankedValue.ENVIRONMENT, 33)
self.assertEqual(33, o.foo)
self.assertEqual(RankedValue.ENVIRONMENT, o.get_rank('foo'))
o.foo = RankedValue(RankedValue.FLAG, 44)
self.assertEqual(44, o.foo)
self.assertEqual(RankedValue.FLAG, o.get_rank('foo'))
示例3: test_unknown_values
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [as 別名]
def test_unknown_values(self):
o = OptionValueContainer()
o.foo = RankedValue(RankedValue.HARDCODED, 1)
self.assertEqual(1, o.foo)
with self.assertRaises(AttributeError):
o.bar
示例4: test_standard_values
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [as 別名]
def test_standard_values(self):
o = OptionValueContainer()
o.foo = 1
self.assertEqual(1, o.foo)
with self.assertRaises(AttributeError):
o.bar
示例5: test_deepcopy
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [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.
示例6: test_indexing
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [as 別名]
def test_indexing(self):
o = OptionValueContainer()
o.foo = RankedValue(RankedValue.CONFIG, 1)
self.assertEqual(1, o['foo'])
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['bar']
示例7: test_deepcopy
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [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)
示例8: test_forwarding
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import foo [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)