當前位置: 首頁>>代碼示例>>Python>>正文


Python OptionValueContainer.add_forwardings方法代碼示例

本文整理匯總了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']
開發者ID:godwinpinto,項目名稱:pants,代碼行數:11,代碼來源:test_option_value_container.py

示例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.
開發者ID:pcurry,項目名稱:pants,代碼行數:13,代碼來源:test_option_value_container.py

示例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)
開發者ID:MathewJennings,項目名稱:pants,代碼行數:13,代碼來源:test_option_value_container.py

示例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']
開發者ID:pcurry,項目名稱:pants,代碼行數:16,代碼來源:test_option_value_container.py

示例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'))
開發者ID:Gabriel439,項目名稱:pants,代碼行數:17,代碼來源:test_option_value_container.py

示例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)
開發者ID:pcurry,項目名稱:pants,代碼行數:18,代碼來源:test_option_value_container.py

示例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)
開發者ID:digwanderlust,項目名稱:pants,代碼行數:10,代碼來源:test_option_value_container.py


注:本文中的pants.option.option_value_container.OptionValueContainer.add_forwardings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。