本文整理匯總了Python中pants.option.option_value_container.OptionValueContainer.bar['b']方法的典型用法代碼示例。如果您正苦於以下問題:Python OptionValueContainer.bar['b']方法的具體用法?Python OptionValueContainer.bar['b']怎麽用?Python OptionValueContainer.bar['b']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pants.option.option_value_container.OptionValueContainer
的用法示例。
在下文中一共展示了OptionValueContainer.bar['b']方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_deepcopy
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar['b'] [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.
示例2: test_deepcopy
# 需要導入模塊: from pants.option.option_value_container import OptionValueContainer [as 別名]
# 或者: from pants.option.option_value_container.OptionValueContainer import bar['b'] [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)