本文整理匯總了Python中webapp2.Config.load_and_get方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.load_and_get方法的具體用法?Python Config.load_and_get怎麽用?Python Config.load_and_get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webapp2.Config
的用法示例。
在下文中一共展示了Config.load_and_get方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_override_config2
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_override_config2(self):
config = Config({
'resources.i18n': {
'timezone': 'America/Sao_Paulo',
},
})
assert config.load_and_get('resources.i18n', 'locale') == 'en_US'
assert config.load_and_get('resources.i18n', 'timezone') == 'America/Sao_Paulo'
示例2: test_default_config
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_default_config(self):
config = Config()
from resources.template import default_config as template_config
from resources.i18n import default_config as i18n_config
assert config.load_and_get('resources.template', 'templates_dir') == template_config['templates_dir']
assert config.load_and_get('resources.i18n', 'locale') == i18n_config['locale']
assert config.load_and_get('resources.i18n', 'timezone') == i18n_config['timezone']
示例3: test_default_config_with_non_existing_key
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_default_config_with_non_existing_key(self):
config = Config()
from resources.i18n import default_config as i18n_config
# In the first time the module config will be loaded normally.
assert config.load_and_get('resources.i18n', 'locale') == i18n_config['locale']
# In the second time it won't be loaded, but won't find the value and then use the default.
assert config.load_and_get('resources.i18n', 'i_dont_exist', 'foo') == 'foo'
示例4: test_override_config
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_override_config(self):
config = Config({
'resources.template': {
'templates_dir': 'apps/templates'
},
'resources.i18n': {
'locale': 'pt_BR',
'timezone': 'America/Sao_Paulo',
},
})
assert config.load_and_get('resources.template', 'templates_dir') == 'apps/templates'
assert config.load_and_get('resources.i18n', 'locale') == 'pt_BR'
assert config.load_and_get('resources.i18n', 'timezone') == 'America/Sao_Paulo'
示例5: test_missing_default_config
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_missing_default_config(self):
config = Config()
assert config.load_and_get('webapp2', 'foo') == 'baz'
示例6: test_missing_key
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_missing_key(self):
config = Config()
config.load_and_get('resources.i18n', 'i_dont_exist')
示例7: test_missing_module2
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_missing_module2(self):
config = Config()
assert config.load_and_get('i_dont_exist') == 'baz'
示例8: test_required_config
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_required_config(self):
config = Config()
config.load_and_get('resources.i18n', 'required')
示例9: test_get_with_default_and_module_load
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_get_with_default_and_module_load(self):
config = Config()
assert config.load_and_get('resources.i18n', 'locale') == 'en_US'
assert config.load_and_get('resources.i18n', 'locale', 'foo') == 'en_US'
示例10: test_get_with_default_and_none
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_get_with_default_and_none(self):
config = Config({'foo': {
'bar': None,
}})
assert config.load_and_get('foo', 'bar', 'ooops') is None
示例11: test_get_with_default
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_get_with_default(self):
config = Config()
assert config.load_and_get('resources.i18n', 'bar', 'baz') == 'baz'
示例12: test_get
# 需要導入模塊: from webapp2 import Config [as 別名]
# 或者: from webapp2.Config import load_and_get [as 別名]
def test_get(self):
config = Config({'foo': {
'bar': 'baz',
}})
assert config.load_and_get('foo', 'bar') == 'baz'