本文整理匯總了Python中webapp2.Config.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.get方法的具體用法?Python Config.get怎麽用?Python Config.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webapp2.Config
的用法示例。
在下文中一共展示了Config.get方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_setdefault
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_setdefault(self):
config = Config()
assert config.get('foo') is None
config.setdefault('foo', {
'bar': 'baz',
'doo': 'ding',
})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
示例2: test_get
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_get(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
self.assertEqual(config.get('foo'), {
'bar': 'baz',
'doo': 'ding',
})
self.assertEqual(config.get('bar'), {})
示例3: test_update
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_update(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
config.update('foo', {'bar': 'other'})
assert config.get('foo', 'bar') == 'other'
assert config.get('foo', 'doo') == 'ding'
示例4: test_setdefault2
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_setdefault2(self):
config = Config({'foo': {
'bar': 'baz',
}})
assert config.get('foo') == {
'bar': 'baz',
}
config.setdefault('foo', {
'bar': 'wooo',
'doo': 'ding',
})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
示例5: test_get_existing_keys_from_default
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_get_existing_keys_from_default(self):
config = Config({}, {'foo': {
'bar': 'baz',
'doo': 'ding',
}})
assert config.get('foo', 'bar') == 'baz'
assert config.get('foo', 'doo') == 'ding'
示例6: test_get_dict_existing_keys
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_get_dict_existing_keys(self):
config = Config({'foo': {
'bar': 'baz',
'doo': 'ding',
}})
assert config.get('foo') == {
'bar': 'baz',
'doo': 'ding',
}
示例7: test_get_with_default_and_none
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_get_with_default_and_none(self):
config = Config({'foo': {
'bar': None,
}})
assert config.get('foo', 'bar', 'ooops') is None
示例8: test_get_with_default
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_get_with_default(self):
config = Config()
assert config.get('foo', 'bar', 'ooops') == 'ooops'
assert config.get('foo', 'doo', 'wooo') == 'wooo'
示例9: test_get_dict_non_existing_keys
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import get [as 別名]
def test_get_dict_non_existing_keys(self):
config = Config()
assert config.get('bar') is None